[gambit-list] Serial number longevity

Marc Feeley feeley at iro.umontreal.ca
Wed Apr 21 07:34:27 EDT 2010


On 2010-04-21, at 3:56 AM, Mikael wrote:

> Marc,
> 
> What is the lifetime/longevity of serial numbers as returned by (object->serial-number)?
> 
> Thanks,
> Mikael
> 

If the object X has a serial number, that serial number is valid until the moment X is reclaimed by the garbage collector.  After this moment, the serial number may be reused (i.e. the serial number is always a fixnum, and eventually the numbers are recycled).

Here's an example:

Gambit v4.6.0

> (define x (cons 11 22))
> (object->serial-number x)
2
> #2
(11 . 22)
> (##gc)
> #2
(11 . 22)
> (set! x #f)
> 1
1
> 2
2
> 3
3
> (##gc)
> #2
*** ERROR IN (console)@11.1 -- Unbound serial number
(serial-number->object 2)
1> 

Note that the assignment (set! x #f) and the dummy evaluations 1, 2, 3 were required to make the GC reclaim the pair (11 . 22).  The dummy evaluations are to remove all references to the pair from the REPL result history (i.e. the table which gives meaning to #, ##, ###, ...).  By default the REPL result history remembers the result of the last 3 evaluations.

Marc




More information about the Gambit-list mailing list