Hmmm, here's an idea:

How about inside of a static function with type annotations, all
literals are automatically converted into long and doubles, otherwise
behavior stays the same.

So:
(defn ^:static fib ^long [^long n]
 (if (<= n 1)
   1
   (+ (fib (dec n)) (fib (- n 2)))))

is automatically converted to
(defn ^:static fib ^long [^long n]
 (if (<= n (long 1))
   (long 1)
   (+ (fib (dec n)) (fib (- n (long 2))))))

whereas
(defn fib [n]
 (if (<= n 1)
   1
   (+ (fib (dec n)) (fib (- n 2)))))
works the way it always did.

This behavior makes a lot of sense because (I think) the only time you
really gain from literals being primitives is when the variables
around it are also hinted.  Otherwise, the polymorphic nature of the
variable will cause the literal to get boxed anyway.

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