Equality of Recursive Structures [Was: Closure Compiler in 3.9 ?]

Lukas Renggli renggli at gmail.com
Fri May 11 18:55:47 UTC 2007


> There is a reason why this is not done in Smalltalk. Have a look at
> the examples below:
>
> aClass>>add: a with: b
>     b = 0 ifTrue: [ SomeGlobal := thisContext ].
>     ^ self add: a with: b+1
>
> aClass>>add: a with: b
>     self become: #zork.
>     ^ self add: a with: b+1
>
> aClass>>add: a with: b
>     self class removeSelector: #add:with:.
>     ^ self add: a with: b+1
>
> There is an infinite number of other examples.

One more example, that is even more striking and that doesn't use
nasty reflection tricks. Imagine that #add:with: was called from a
subclass implementation using super. Recycling the stack would clearly
change the behavior of the code:

A>>add: a with: b
     ^ self add: a with: b+1

B>>add: a with: b
     ^ super add: a + 1 with: b

Cheers,
Lukas

-- 
Lukas Renggli
http://www.lukas-renggli.ch



More information about the Squeak-dev mailing list