On Wed, May 5, 2010 at 11:11 AM, Sean Devlin <[email protected]>wrote:

> I think there's a fundamental assumption that I disagree with.
>
> Since we've already opened the can of worms that is auto-promotion, it
> should *always* work.  Given auto-promotion, + shouldn't be fast (use
> unchecked-add), it should be predictable.  Same for -, * and friends.
> Quality is more important than performance, principle of least
> surprise, etc.
>
> Sean


unchecked arithmetic operations are discouraged because ... they are
unchecked. + is fast *and* it checks for overflow on primitive types. Again
+ is not doing any auto-promoting here. Putting a primitive in a var is.
Case 1 in the OP is the surprise for those who don't know that. Case 2 is
the correct behavior that I've come to expect from + when passing in
primitive types.

For those who rely on fast arithmetic, having +, * and friends be slow is
simply unacceptable (and that's not a small number of Clojurians, and it
should include anyone wishes to see a performant Clojure written in itself).

This is a conceptual break from some other dynamic languages - but then the
performance guarantees of those languages is nothing to brag about either.
Clojure ships with great performance guarantees - that's a feature.

David

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to