Some Self ideas

Mark van Gulik ghoul6 at home.net
Sat Jan 20 19:15:52 UTC 2001


on 1/20/01 10:54 AM, Bijan Parsia at bparsia at email.unc.edu wrote:
[...]
>> Teaching to a newbie could be easier if we can say 'all is
>> polimorphic'...
> 
> *Could be*, maybe. I'd claim that it *isn't* if by "all is
> polymorphic" you mean that your proposal is the way to go ;)
> 
> Plus, there are varieties of newbies (e.g., newbie smalltalks but expert
> lispers, newbie programmers, newbie oo programmers, etc.) Who are we
> optimizing for with this? Who are with *disoptimizing* for (optimization
> involves trade offs).

Funny you should mention Lispers.  Most of them seem quite happy when
expressions like "(car 'x)" return nil.  Bizarre.  I can't imagine the
millions of bugs masked (at least hidden for a long time) by this behavior.
Yet if memory serves, all the major Lisp implementations have supported this
absurdity.  I guess it had something to do with the cost of resubmitting a
batch job in the early days or something.  Then again, they used the empty
list to represent false.  It shortens the code, but at what expense?  Even
QKS Smalltalk supported using the integer 0 interchangeably with false.
Fine for the 0.001% of Smalltalk code that does bit-twiddling, but is really
worth corrupting the Number hierarchy?  Far too C-ish for my taste.  By the
way, even C++ supports a separate boolean type now (although it's treated as
a numeric type for compatibility).  There *are* cases where treating 0 as
false and 1 as true is efficient.  For example, max(a,b) can be defined as
(a+(a>b)*(b-a)), which avoids branching (if your CPU & compiler can transfer
the comparison result, typically the carry bit, into a register suitable for
multiplication).  Oh, and you'd better not use the result of some
boolean-valued function instead of (a>b), because it might really be
returning *non-zero* for true instead of *one* for true (like strcmp is
allowed to do).  Sad stuff, prone to *lots* of problems.

VisualWorks included an implementation of #value in Object for a short
while.  There was no end of trouble from *that* little gem.  Obviously they
removed it pretty quickly.  I myself had to use a framework that relied on
#value in Object ^ing self.  It would mask at least one bug a week, usually
taking on the order of an hour to locate.  It's as bad as the hacks that
UIBuilder uses, completely masking DNU's.  Code smell like you wouldn't
believe.  After a few months of having Object>>value disguise my bugs (I'm
far too lenient towards the terrible ideas of others) I ripped the method
right out.  Literally *dozens* of bugs suddenly scuttled out from under that
method, scurrying for new cover under intention-hiding pathological
polymorphism.





More information about the Squeak-dev mailing list