You are looking at historical revision 24488 of this page. It may differ significantly from its current revision.
An implementation of serialnumbers and their arithmetic as described in http://www.faqs.org/rfcs/rfc1982.html.
(use serial) ;;simple addition (display (sn+ 1 2)) ;;wrapping (display (sn+ (sn+ 6 3 bits: 3) 2 bits: 3)) ;;comparision (sn> 3 4) (sn< 3 5) (sn= 4 4 bits: 10)
The library defines a small set of procedures that can be used to bring serial-number arithmetic to regular fixnums. There are however certain requirements for a number to be usable as a serial-number. It must be a non-negative fixnum, that does not exceed the allowed range for a given operation.
Every procedure accepts a keyword-argument key which specifies the number of bits used to represent the biggest acceptable serialnumber for that operation. This is especially important when addtion is performed on boundary values which causes a wrap-around.
Is set to 32.
Addition[procedure] (sn+ serial fixnum #!key (bits +default-serial-bits+))
Adds fixnum to the supplied serial and returns the result of the addition. Note that this procedure may wrap the value if the given serial is the upper boundary value of the range of integers that can be represented using bits bits. This means that (sn> (sn+ serial 1) serial) may be false in this situation.
The standard set of comparison operators that can be applied to fixnums are available for serial-numbers too. They're all prefix by sn. Please refer to 3.2 on http://www.faqs.org/rfcs/rfc1982.html for details on the semantic of those operations. Most of the time they will however have the same sematics as the corresponding procedures on the set of regular fixnums.[procedure] (sn> s1 s2 #!key (bits +default-serial-bits+))
[procedure] (sn< s1 s2 #!key (bits +default-serial-bits+))
[procedure] (sn<= s1 s2 #!key (bits +default-serial-bits+))
[procedure] (sn>= s1 s2 #!key (bits +default-serial-bits+))
[procedure] (sn= s1 s2 #!key (bits +default-serial-bits+))