Hi Meikel,

Meikel Brandmeyer wrote:

> On Mon, May 31, 2010 at 07:34:24AM +0200, Sina K. Heshmati wrote:
> 
>> > (defn make-module
>> >   []
>> >   (let [state (atom 0)
>> >         say-hello (fn [] (println "Hello"))
>> >         public-op (fn [x y] (+ @state x y))]
>> >     (fn [op]
>> >       (case op
>> >         :hello  say-hello
>> >         :public public-op))))
>>
>> Could you elaborate a bit please? Is there a reason why nested defns are 
>> wrong?
> 
> I'm sorry. I missed this question.

Thanks for the follow-up.

> def always introduces a global binding. It is unlike schemes define.
> So invoking make-module twice basically overwrites the first defs
> with the second ones.

I see now. I used to think of them as defines in Scheme but I started to notice 
this when I saw them survive closures.

Kind regards,
SinDoc

-- 
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