Smalltalk Design Question

Vassili Bykov vassili at objectpeople.com
Wed Jan 28 01:45:23 UTC 1998


Andreas Raab writes:
 > >From my point of view (I am _not_ one of the "original" smalltalk
 > designers) it's just the other way around. In a static language you have
 > all the time you need for compiling and linking and doing case insensitive
 > comparisons.  Smalltalk, however, does lots of things with its selectors.
 > You can "perform:" them which is in basically a lookup of the signature. 
 > In principle, this happens every time a message is sent.  I'd say if the
 > method lookup takes longer for case-insensitive comparisons this a very
 > good reason to stay case insensitive. 

(That last word is probably supposed to be "sensitive".)  

Method lookup speed should not depend on case (in)sensitivity at all.
What is compared during lookup are the *identities* of selectors.
Those selectors, Symbols, are created (or fetched from the Symbol
table) at compilation time and stored in the CompiledMethods' literal
frames and message dictionaries.  Lookup machinery works with those
Symbols' object pointers (and probably the pointers' hash values).
Case does not matter at all.

Case insensitivity can be trivially introduced by converting all
relevant symbols (those identified as selectors by the Parser) to
upper or lower case during compilation.  This is how most Lisp and
Pascal implementations solve the issue.  All it would take to make
Smalltalk case-insensitive would likely be a single "asLowercase" in
the right place in the Parser.  (OK, that doesn't mean you can just go
ahead and do that in an existing Smalltalk system, for obvious
reasons).  The price of insensitivity would thus be one #asLowercase
per symbol during compilation, which is minuscule.  So, if there
actually is/was a reason, it is not performance.

Note however, that case does play a semantic role in variable names:
capitalization determines a variable scope.  In a language with
case-sensitive variable names, it is quite natural to expect
case-sensitive func... oops, selectors -- if only for the sake of
consistency.

Finally, case sensitivity might simply be a matter of someone's
personal concept of The Right Thing (tm).

--Vassili

-- 
Vassili Bykov        vassili at objectpeople.com
The Object People    http://www.objectpeople.com
+1(613)225-8812





More information about the Squeak-dev mailing list