2013/4/24 Bradley Lucier
<lucier@math.purdue.edu>
On 04/24/2013 12:37 PM, Zhen Shen wrote:
[...]
> Now, doing (declare (flonum)) at the top level, does this stop gambit
> from boxing flonums across function calls?
No. Gambit keeps flonums unboxed inside a basic block, whenever there's
a jump (or the possibility of a jump), Gambit boxes up all the
still-needed flonums.
What about fixnums, would they remain unboxed in a loop?
Also btw, are there any tricks that can be applied to make it keep flonums and fixnums unboxed in loops, like, (declare (not interrupts-enabled)) or (not safe)?
Btw, there was a conversation on the following like ~4y ago though I don't remember the conclusion:
In a context where the user is allowed to enter any value, what's the most performant way to ensure the value is made a flonum or integer?
(Or, you made some nice calculation that made use of the numeric tower's exactness but you get to a point where you want to ensure a proper cast to flonum or integer:)
I.e,. what's the fastest way to do (exact->inexact n) and (inexact->exact (floor n)) respectively, where examples for n are 5 5. 3/7 1e25 ? :)
If I remember right from that conversation there were some Huge differences in performance between different approaches, like 500x.
Brgds,
Mikael