C
Chris Uppal
Mike said:This is the use of anonymous classes which would be solved equally well by
method pointers, which are conceptually much simpler (or at least more
familiar from other C-base languages.) I find Sun's white paper extolling
the virtues of anonymous classes over method pointers quite unconvincing.
Now there, I agree with Sun (as far as I remember the paper). The guy (I
forget his name -- something Nordic) who introduced them into Delphi (or Object
Pascal or whatever it was then called), went on to introduce them into the
Borland C++ product (where they had no place /at all/), and then went to work
at MS where he has introduced them into everything (it seems) he touches.
The guy's a veritable Typhoid Lizzie. He suffers from some weird obsession
with the concept...
I don't think they have anything to do with, nor are in any way desirable as a
supplement for, OO programming. As an example to support this, in the
Smalltalk I use it is trivial to use the equivalent of "method pointers"
(actually they, MessageSends, are marginally more flexible and powerful).
What's more they are plug-compatible with the less powerful Messages (which
have no bound-in receiver), and with the vastly more powerful (but more
expensive) BlockClosures (which are full, stateful, closures) -- so there is no
barrier to using them whenever they fit the bill. But, in some 8 years as a
Smalltalk user, I have used them twice. Over that same period I must have used
thousands of BlockClosures and Message in contexts where I /might/ have chosen
a MessageSend.
-- chris