Why can't I do (aNonSmallInteger becomeFoward: aSmallInteger)?

Tim Rowledge tim at sumeru.stanford.edu
Sun Mar 31 18:27:38 UTC 2002


Because a SmallInteger is a manifest constant and the oop _is_ the
value. #become: swaps the values refered to by the oop - if the oop is
the value, it can't be swapped. 

You could concievably get the results you want by making a large integer
(which is not a manifest constant) but remember that largeintegers work
quite hard to become SmallIntegers any time you send them any sort of
arithmetic message. You'd probably want to implement a WordInteger class
to get around this, or you could try living with an ugly hack like
simply using a size 4 ByteArray.

tim



More information about the Squeak-dev mailing list