Thanks again - that all makes sense.

One (hopefully) tiny question... an efficiency one... (and feel free not to 
answer it if I've already taken up enough of your time)

If you do that and are careful, the performance of next/nil? is slightly 
> better than rest/empty?.
>

If I use the next/nil? idiom, is there a performance difference between 
doing:

   1. (if (nil? xs) a b)
   2. (if xs b a)

And a related question...  Clojure has two falsey values: nil and false.  I 
assume that low-level somewhere, when checking for falsey, an (if x a b) 
call will do something like "if x is false, short circuit to b, if x is 
nil, short circuit to b, otherwise a".  Except, I don't know which gets 
priority of place with the short circuits - is it false (as I've just 
written), or is it nil?

Actually, if I'm thinking about it correctly...

If false takes priority then...  A branch to "a" will take three tests for 
1. and two tests for 2....  And a branch to "b" will take two tests for 1. 
and two tests for 2..

If nil takes priority then...  A branch to "a" will take three tests for 1. 
and one test for 2....  And a branch to "b" will take three tests for 1. 
and two tests for 2..

So 2. is always as good or better than 1. I think - performance wise.

Of course, these things are very much minor factors in overall performance 
(especially when things like immutable data structures are involved), but I 
wouldn't mind knowing.

Cheers,

Mark.

-- 
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/d/optout.

Reply via email to