On Friday, February 22, 2013 8:23:38 PM UTC+1, David Nolen wrote:
>
>  
>
>>  I'll give you one specific item that I keep tripping upon: the lack of 
>> reassignable, stack-based locals. Without them I can't efficiently get more 
>> than one value out of a loop. Another item is that I can get zero primitive 
>> values out of a loop. How do you cope with those?
>>
>
> Some ideas for the first point:
>
> * atoms
>

These are thread-safe and nowhere near as efficient as stack-based locals.
 

> * implement efficient tuple type which uses mutation for multiple value 
> return
>

Basically, this is the ^:unsynchronized-mutable that we just mentioned :) 
This is much better, but still it's not stack-based, so incurs the cost of 
allocation and GC.
 

> I suspect the second option will be pretty fast. Annoying, but that's a 
> tradeoff with Clojure's mostly functional design.
>

Annoying *and* slower than Java's locals, unfortunately. Most of the time 
it won't make a huge dent in the performance, but I just happen to have an 
inner loop that iterates between zero and three times only, zero being by 
far the most common case, and is entered many times from the surrounding 
loop. The performance drop is considerable.
 

> Second point, I think 1.5.0 addresses that to some degree thanks to 
> Christophe.
>

As far as I got it, it only prevents loop-recur from destroying the 
primitive-returning semantics of functions. Loops used within function 
bodies stay the same.
 

> Heh, I always point out test.benchmark - 
> http://github.com/clojure/test.benchmark. There's some horrifying stuff 
> in there ;)
>

I remember you mentioning that on StackOverflow, maybe it's time for me to 
check it out more seriously.

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