>Hi Thanks for the super fast response, Still a little confused. If coll is
set to nil before >reduce is called, then what is reduce called with?

Remember, the JVM is a stack machine (before the JIT is run). So the code
produced is something like this:

push coll
push nil
pop-into coll
call-fn reduce

Timothy


On Tue, Feb 5, 2013 at 9:31 AM, Herwig Hochleitner
<hhochleit...@gmail.com>wrote:

> 2013/2/5 N8Dawgrr <nathan.r.matth...@gmail.com>
>
>> Hi Thanks for the super fast response, Still a little confused. If coll
>> is set to nil before reduce is called, then what is reduce called with?
>
>
> It's called with the value coll had right before it being set to nil.
>
> Clojure even has Util.retl, with a dummy arg, to do this even in plain
> java, for example:
> https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L3458
>
> Jim:
>
> > Couldn't the compiler infer that the 2 expressions are identical with
> identical arguments and perform the reduce only once? Basically what the
> programmer would do in a let statement? Would that be too expensive?
>
> No the compiler could only do that, if it knew that reduce (and its
> reducing fn) has no side effects. Clojure has no mutability analysis.
>
> --
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to