Unexpected MetaClass Behavior

Jon Hylands Jon at huv.com
Wed Jul 12 14:26:07 UTC 2000


On Wed, 12 Jul 2000 09:39:21 -0400, Mark Guzdial
<guzdial at cc.gatech.edu> wrote:

> Obviously, what the students were TRYING to do was to set an instance 
> variable named "name."  What I expected the below code to do was to 
> refuse to compile, saying that "name" wasn't a variable known to that 
> method.  But it did compile, and it works! In a class message, the 
> variable 'name' corresponds to the name of the class, and setting it 
> changes the name of the class.

In Visual Smalltalk (older versions), it was even worse. Since there
were no real contexts, you could define 'name' as a temp var or a
block argument in a class method, and the compiler didn't complain. It
also cheerfully renamed the class to whatever object you assigned to
the temp/block variable.

Later,
Jon

--------------------------------------------------------------
   Jon Hylands      Jon at huv.com      http://www.huv.com/jon

  Project: Micro Seeker (Micro Autonomous Underwater Vehicle)
           http://www.huv.com





More information about the Squeak-dev mailing list