In my own code I only avoid the convenience of destructuring in the
rare tight loops such as calculations intended to drive animations.
I've found it to have little effect elsewhere on program performance.

As an aside I personally prefer non positional keyword arguments. I
find positional ones quite tedious.

David

On Thursday, April 8, 2010, Sophie <itsme...@hotmail.com> wrote:
> On Apr 7, 7:56 am, David Nolen <dnolen.li...@gmail.com> wrote:
>> The runtime cost of destructuring is not worth getting worked up
>> about. It's easy to check this yourself with (time ...)
>
> Results below:
>
> user=> (defn fk [& {:keys [a b c]}] (+ a b c))
>
> user=> (defn fp [a b c] (+ a b c))
>
> user=> (time (dotimes [_ 1000000] (fk :a 2 :b 2 :c 2)))
> "Elapsed time: 1582.178 msecs"
>
> user=> (time (dotimes [_ 1000000] (fp 2 2 2)))
> "Elapsed time: 319.243 msecs"
>
> Not sure how significant that would be in user code, but I'd rather
> not have to choose less a less readable version because of the hit.
> Positional keywords would give the readable function calls without the
> run-time hit (and we could still use optional &keys if they were
> somehow distinguished in the function calls).
>
> --
> 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 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

To unsubscribe, reply using "remove me" as the subject.

Reply via email to