On Thu, Jun 14, 2012 at 8:09 AM, Jim - FooBar(); <jimpil1...@gmail.com> wrote:
> (doto foo
>  (.bar x)
>  (.baz y)
>  (dotimes [i 10] (.zab g)))
>
> won't work because foo is substituted as the second argument of 'dotimes'!
> It has to be 'do' instead of 'doto'...
>
> very subtle trap...
>
> Jim

I think the "trap" here (if there is one) is that coming from another
language, you might believe that "doto" is setting some magical
"context" value. For instance, the with statement in javascript does
some sort of magic to alter the "current scope".

If you understand that "doto" is simply a macro that alters the source
code that it is invoked upon, it's pretty clear what is wrong with
your code. This same understanding then applies to all the other
similar macros (.., ->, ->>). None of them are doing anything other
than rearranging source code.

--Aaron

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