[ENH] honest

ok at cs.otago.ac.nz ok at cs.otago.ac.nz
Mon Jun 16 02:11:37 UTC 2003


from preamble:

"Change Set:		honest
Date:			16 June 2003
Author:			Richard A. O'Keefe

#respondsTo: is one of the core messages in
Smalltalk; it has been around for a long time
and is clearly specified in the ANSI standard.
However, there seems to be wide confusion
even among experienced Smalltalk programmers
about what it is supposed to do.  ANSI is clear:
(anObject respondsTo: aSelector) when and only
when there is an implementation (ANY kind of
implementation) for aSelector in anObject's
behaviour.  That is, when you won't get an
immediate Message Not Understood on sending.

This means that the distressingly common idiom
  (foo respondsTo: #bar) ifTrue: [foo bar]
has never worked, will never work, and
doesn't work now.  For example,
  (1 to: 10) respondsTo: #at:put:
answers true, but if you try
  (1 to: 10) at: 1 put: 2
you will be told immediately that you should
have known better than to try such a silly
thing.  (OK OK that's not the actual words.)

This change set
(1) amplifies the comments in
    Object>>respondsTo: and
    Behavior>>canUnderstand
(2) adds new methods
    Object>>honestlyRespondsTo: and
    Behavior>>canHonestlyUnderstand:
    (and an method in CompiledMethod just to
    support these ones)
If you have been using #respondsTo:, you
may find that #honestlyRespondsTo: is closer
to what you really wanted; similarly
#canHonestlyUnderstand may be a better match
for your intentions than #canUnderstand."!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: honest.cs.gz
Type: application/octet-stream
Size: 2208 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20030616/d0435665/honest.cs.obj


More information about the Squeak-dev mailing list