> I've also temporarily enabled a diagnostic (in both) that tells you
> when you have a mismatch between a loop initializer and its recur
> form. It goes off over a hundred times in Clojure itself, when using
> the arbitrary precision default. In each case, the recur value is
> needlessly being boxed, every iteration of a loop, for loops that will
> never be bigints; indexes, counters etc. I expect this will be very
> typical of most code. But removing that useless overhead would be a
> lot of tedious work.
>
> With the defaults swapped, only 2 warnings.
>

How often does the warning go off if you go back to
arbitrary-precision by default, but make literals return boxed numbers
again? I suspect your comparison is unfair because lots of the loop
initializers are probably literals.

---

A concern I have is that interop forms that return primitives can
cause a loop var to have a primitive type.

(loop [procs (.availableProcessors Runtime/getRuntime)] ; Current
clojure makes procs a primitive, do people really expect that?

Would it be possible for loop to use boxed numbers always by default,
and only use primitives if some specific metadata is on the
initializer?

So in that world:

(loop [i 5] ; Boxing is always done by the loop statement, even if
initialized with a primitive

(loop [procs (.availableProcessors Runtime/getRuntime)] ; Boxing is
done by the loop statement

(loop [^:primitive procs (.availableProcessors Runtime/getRuntime)] ;
Primitive is used, good because we are expecting it


I'm not sure which order the metadata should go in such a scheme.

(loop [^:primitive i 5]
(loop [i ^:primitive 5]
(loop [i (prim 5)]

--Aaron

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