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

Andreas Raab Andreas.Raab at gmx.de
Sun Mar 31 19:21:12 UTC 2002


> Yes, but he's talking about #becomeForward:, not #become:
> 
> So, there is a good question why it doesn't/can't work.

Same issue in both cases. SmallIntegers are not referenced - they are
always used 'by value'. Thus, whenever you 'use' or 'reference' a
SmallInteger you are actually creating a copy of that SmallInteger (just
in the most efficient way possible). Which effectively means that
#becomeForward: could (at best) be a no-op, since what you're really
getting is something like
	1 copy becomeForward: 2 copy.
However, since we give users the illusion that there is only a single
SmallInteger '1' in system (by implementing identity comparison
appropriately; e.g., '3+1 == 5-1' => true) the meaning of
#become:/#becomeForward: would have to be to change _all_ instances of
the SmallInteger in question. And that's something you _definitely_ do
not want (believe me).

Cheers,
  - Andreas





More information about the Squeak-dev mailing list