In this branch
https://github.com/clojure/clojurescript/compare/master...checked-arithmetic,
I've implemented one possible approach to checked arithmetic for
ClojureScript. In Clojure this means checking for overflow. In JavaScript a
much more common source of error is type coercion from the arithmetic
operators as well as the introduction of Infinity and NaN.

These changes would prevent the production of NaN and Infinity at least
from within ClojureScript itself. Also operations like:

(+ 1 2 "3")

fail instead of producing

"33"

Of course such changes would impose a performance hit. You can currently
toggle the behavior with the following macro:

(set-unchecked-arithmetic! true)

This is useful when writing performance sensitive code.

Feedback, improvements appreciated.

David

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

Reply via email to