Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Actions and bindings
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
christophe@cgrand.net  
View profile  
 More options Mar 14 2008, 12:20 pm
From: "christo...@cgrand.net" <christophe.gr...@gmail.com>
Date: Fri, 14 Mar 2008 09:20:59 -0700 (PDT)
Local: Fri, Mar 14 2008 12:20 pm
Subject: Actions and bindings
I know that threads do not inherit dynamic bindings but wouldn't
actions be an exception?
Since they are executing in a random thread of a thread-pool it
doesn't make sense to have per-thread binding. Does it?

> (def a (agent nil))
> #<Var: user/a>
> user=> (def b "root")
> #<Var: user/b>
> (binding [b "bound"] (send a (fn [av] (println b) (flush))))
> clojure.lang.Agent@18c6cbc
> root

If actions was allowed to inherit dynamic bindings, I would expect
this to print "bound".

What do you think? Is it a silly idea?
(Maybe cross-thread bindings inheritance is currently an expensive
operation, and, so, such a feature would go against the grain of
Clojure's design).

Christophe


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rich Hickey  
View profile  
 More options Mar 14 2008, 5:00 pm
From: Rich Hickey <richhic...@gmail.com>
Date: Fri, 14 Mar 2008 14:00:54 -0700 (PDT)
Local: Fri, Mar 14 2008 5:00 pm
Subject: Re: Actions and bindings

On Mar 14, 12:20 pm, "christo...@cgrand.net"

The first thing to remember is that the second argument to send is a
regular fn object. It might be created in place, it might have been
created prior. The behavior needs to be the same in either case.

Second, if there was child-thread binding inheritance, it would occur
on thread creation. But the threads created for agents might a)
already exist, or b) be created outside the dynamic scope of the
action send.

Third, there might be many dynamic bindings, and an action might not
utilize any of them. Copying them in all cases would be significant
overhead.

In any case, it is possible to create an action with precisely the set
of bound vars you want:

(send a (fn [av] (binding [b "bound"] (println b) (flush))))

If this becomes a common thing, a little macrology could make it
painless.

Rich


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »