From: Pascal Bourguignon
Subject: float boxing
Date: 
Message-ID: <87vf9y54tw.fsf@thalassa.informatimago.com>
* (list x y z)

(1.0 0.0 1.0)
* (eq x z)

NIL
* (setq x z)

1.0
* (eq x z)

T
* 

Now, since (eq x z), obviously when doing: (incf x y)
we must allocate a new float for x.


* (incf x y)

1.0
* (eq x z)

NIL
* 

But I'm wondering, if we kept all floats NOT EQ, we could avoid
allocating new space.  Since there would be no two pointers to the
same float instance, we could modify its value without any problem.
So while we would use a little more space than in static languages for
the pointer, we could have the same speed performance without any need
for boxing/unboxing.

Or perhaps it wouldn't be a gain because we more often pass floats as
parameters (which means we'd need to copy them every time) than
operate on them?

(On a 72-bit machine we could even do without the pointer to the
single-float & double-float.)


The same thing could be done for bignums too, while the trade-off
would be more problematic: it might be worthwhile if we do a lot of
(INCF bignum 1) operations, but for (setf bn1 (* bn1 bn2)) we would
need to allocate new space anyway...


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
The rule for today:
Touch my tail, I shred your hand.
New rule tomorrow.