Hi,

On Oct 6, 1:23 am, MarkSwanson <mark.swanson...@gmail.com> wrote:

> I wonder if this concept will be thought of as a source of problems in
> the future. Or, maybe this is just one of those fundamental Clojure
> concepts you just have to learn and once you do you find you don't get
> bit by it.

This is a side-effect of lazyness. One has to pay close attention how
the evaluation of code works. And Clojure provides enough means to
tell it specifically what you want. doall is such a construct. Lazy is
the default (and the right one at that), but if necessary you can tell
Clojure to be eager.

Vars work similar. Their notion is "thread-local". That is a "parallel
universe where good Kirk and bad Kirk never meet", as Rich put it in
his recent talk. The "universe" is at the moment one thread. That
causes problems if you call send on an agent. That action happens on
another thread, hence eventual special bindings are not in effect.

And again, Clojure will provide a construct (namely bound-fn) to the
programmer, so that he can express his intent. It allows to extent the
universe to other threads (or later points in time). It's not
finished, yet. Here the assembla ticket and a recent discussion.

http://www.assembla.com/spaces/clojure/tickets/170
http://groups.google.com/group/clojure/browse_thread/thread/d4a30c8bc18ed5ab

The usage would be:

(defn baz
  [x]
  (map (bound-fn [_] (foo)) x))

or

(def a (agent nil))

(defn baz
  [x]
  (send a (bound-fn [_] (foo))))

Note: this is not necessary in general. Eg. generating a sequence
should not depend on some distant Var. Similar eg. agent actions
should be pure functions of the state (and eventual other arguments to
send).

Sincerely
Meikel

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to