About KCP and automatic initialize

Lex Spoon lex at cc.gatech.edu
Tue Sep 16 16:55:38 UTC 2003


It sort of amuses me that Squeak seems to be the first Smalltalk to
conform to ANSI (if you load the right packages), and now we are about
to *break* conformance before the other Smalltalks even get on board. 
:)  This is wildly surprising to me, because Squeak is supposed to be
the wild and wooly Smalltalk; ANSI is supposed to be for
staid-and-steady systems.

Here are two ideas to smooth this transition.

First, you can still write mostly-ANSI code to be portable by writing
your new methods as follows:

	new
		^self basicNew initialize

This way, you don't care what the default #new method does, because you
are using basicNew instead.  The more I think about it, the more this
seems like a good pattern, anyway, once you start thinking about deep
class hierarchies.

Second, it would be nice to have a preference around for strict ANSI
conformance.  I hate preferences, but this really is a system-wide flag
that impacts a variety of things, and that will have many people
desiring each setting.  Then the default #new implementation can check
the preference.  It would be even better if individual packages could be
loaded in ANSI mode, but that seems quite tricky to do.  At the least we
would need mature namespaces for classes.

Only slightly inferior is if the ANSI compatibility package overwrites
the #new method.  But in that case you *really* have to choose whether
you want the ANSI package loaded, as opposed to the current situation
where it stays out of your way if you aren't using it.

Better would be if selectors could be re-interpreted based on who is
sending them, i.e. if there were namespaces for selectors, too.  Hmm,
actually, this is doable for the particular case of ANSI, even though it
seems complicated to solve this in general.  Take every selector which
has different interpretations -- e.g. #new -- and replace it in the
package by #ansiNew.  Have the default version of #ansiNew call #new,
but replace it with an ANSI definition as desired.  As for what to do if
a user modifies such a method, well, that's more complicated.  It would
be important to realize that the method under modification is part of an
ANSI package, but that gets back to the question of knowing which
methods are part of which package that has gone around a time or two.


-Lex



More information about the Squeak-dev mailing list