Message-ID: <328A8277.2702@parcplace.com>
Date: Wed, 13 Nov 1996 18:22:47 -0800
From: Brad Horstkotte <brad@parcplace.com>
Organization: ParcPlace-Digitalk, Inc.
X-Mailer: Mozilla 2.0 (Win95; I)
MIME-Version: 1.0
Subject: Re: Conclusion: Q: isNil OR: == nil ??
References: <3285F093.339F@kommsrv.rz.unibw-muenchen.de> <3289BB7C.6839@kommsrv.rz.unibw-muenchen.de>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: comp.lang.smalltalk
Lines: 33
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!portc01.blue.aol.com!portc02.blue.aol.com!howland.erols.net!vixen.cso.uiuc.edu!sdd.hp.com!frankensun.altair.com!daffy!uwvax!news.heurikon.com!news.dpc.net!novia!nntp2.rmci.net

> 2) the semantics may be different: Paul wrote:
> anObject == nil says "are you the unique object known as <nil>" while
> anObject isNil says "do you exhibit 'nil' behaviour"; I can imagine
> situations where you might want an object to answer <true> to isNil even
> though it is not the unique nil object.

Part of the confusion is due to the fact that there are other such testing methods like #isNumber, 
which test essentially whether the receiver isKindOf: whatever the class suffix is (is the 
receiver a kind of Number); isNil does NOT test whether the receiver is a kind of UndefinedObject 
(if it did it would be called #isUndefinedObject), rather it asks whether the receiver is THE 
distinguished object "nil".  For example, here's the comment from one implementation (Smalltalk/V):

isNil
        "Answer true if the receiver is
         the object nil, else answer false."
    ^false

Redefining #isNil elsewhere in the system with a different semantic should be considered a BUG.

Choosing whether to use "o isNil" or "o == nil" is completely a point of style, and one which finds 
allies on both sides of the fence; personally I prefer #isNil (its part of the proposed X3J20 ANSI 
standard for Smalltalk, why shouldn't it be used?).

Brad
