On Sep 22, 5:52 pm, Phil Hagelberg <p...@hagelb.org> wrote:
> On Thu, Sep 22, 2011 at 2:19 PM, Chouser <chou...@gmail.com> wrote:
> > It looks like each top-level form currently gets its own fresh
> > DynamicClassLoader.
>
> > [...]
>
> > (do (def a #()) (def b #()))
>
> If you'll pardon a nit-pick, this example is somewhat misleading since
> do forms are special-cased by the compiler so that each form they
> contain is treated as a top-level form.
>
> Witness:
>
> (do (def a #()) (def b #()))
> (= (.getClassLoader (class a)) (.getClassLoader (class b)))
> ;; => false
>
> ;; we can avoid the compiler's special-casing
> (when true (def a #()) (def b #()))
> (= (.getClassLoader (class a)) (.getClassLoader (class b)))
> ;; => true
>
> The point you are getting at is correct, but it's better shown without do.

Meta-nitpick: I think the usual way to avoid the special-casing is
(let [] ...), which is in fact what some built-in constructs like
deftype expand to.

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