[BUG?] Missing class checks on send| and send& ?

Bert Freudenberg bert at isg.cs.uni-magdeburg.de
Mon Mar 19 17:15:57 UTC 2001


On Mon, 19 Mar 2001, Bijan Parsia wrote:

> If we take them as short-circuting

The major point to keep in mind in this discussion is that there is
*nothing* special about #&, #|, #and:, or #or:. There's no
short-circuiting on a syntax-level in the Smalltalk language. These are
messages like every other message in the system.

It is a convention the Smalltalk library designers choose to use the
binary messages #& and #| to take a boolean argument - which means it's
always evaluated. Again by convention, the #and: and #or: messages take a
block that is evaluated depending on the receiver, in fact realizing a
"short-circuit".

Another convention is to have two distinguished boolean values, as opposed
to Lisp which treats any non-nil value as true. In Lisp, "(or nil 4)"  is
a legal construct, it does the right thing when answering 4. In Smalltalk,
"false | 4" is somewhat illegal, because the convention is to give it only
boolean arguments. But yet another convention in Smalltalk is to not
enforce conventions (although I've never seen this explicitely stated). 

Adding the checks would have a certain runtime cost, too, so I'd say
"leave dam messages alone" ;-)

-- Bert





More information about the Squeak-dev mailing list