[ANSI-Smalltalk] Protocol extensions - Object
Richard O'Keefe
ok at cs.otago.ac.nz
Fri Sep 26 04:36:26 BST 2008
On 25 Sep 2008, at 9:24 pm, Andres Valloud wrote:
[about #become:]
> I think there is some value in that when it's there, its behavior is
>
> standardized. Perhaps we need to make the distinction of whether a
> particular piece of standard must be implemented? Something like
> this:
>
> * All compliant Smalltalks must implement xyz and xyz must behave
> like this.
>
> * All compliant Smalltalks must either implement xyz so that it
> behaves like this, or not implement xyz at all.
The ISO C89 and ISO C99 standards have a section at the end
about common extensions. To be honest, I read those sections
from time to time to learn what not to use.
Most Smalltalks *will* have some (possibly very slow) support for
#become:, if only for the sake of tradition. It is obviously
desirable that people who choose to use it should be able to do
so in a portable way.
However, #become: is not just tricky to implement in some otherwise
sensible approaches. It is also an intrinsically dangerous operation
in that it can breach encapsulation. E.g., object A hands object B to
object C, which checks that it's OK, then later object A swaps B for D,
which does something else entirely. It belongs in the same group of
"traditional handy-for-low-level-hackery but utterly destructive of
encapsulation" methods as #instVarAt:[put:]. There are advantages in
being able to tell that your program does not rely on such things.
It's nice to be able to use an OO language with reliable encapsulation
called Smalltalk.
So I think Andres has the right compromise. These things _are_ of
historic importance, most Smalltalks have them, it would be nice if
they had them the same way for the occasions when you really do want
to wave a machine gun around near your foot. But if we can possibly
have a core/common extensions split (shades of ISO Pascal!), they
should be kept out of the core.
Me, I'd settle for a file stream interface that didn't assume all
text files were one byte per character, including newline...
More information about the ANSI-Smalltalk
mailing list