[ANSI-Smalltalk] A list of interesting methods, ifNotNil:
Andrew Wakeling
andrew.wakeling at objective.com
Mon Apr 7 01:55:19 BST 2008
I believe Object>>ifNil:ifNotNil: is more consistent with the
Object>>ifTrue:ifFalse:
Perhaps if you wanted to be even clearer, Object>>ifTrueDo:ifFalseDo:
although this may be confusing as the blocks are not only executed but
returned.
Object>>isNil: isn't clear to me. It particularly looks like a setter
method. Consider this case with testing methods.
e.g. SomeObject>>isModified or SomeObject>>isModified:
I do like Object>>isNil and Object>>notNil and believe it is consistent
with above.
Zak
-----Original Message-----
From: ansi-smalltalk-bounces at lists.openskills.org
[mailto:ansi-smalltalk-bounces at lists.openskills.org] On Behalf Of cstb
Sent: Tuesday, 25 March 2008 1:13 PM
To: Discussion list for the ANSI Smalltalk project
Subject: Re: [ANSI-Smalltalk] A list of interesting methods, ifNotNil:
At 01:08 AM 3/20/2008, you wrote:
>John Dougan wrote:
>>Ralph Johnson wrote:
>>>>Object>>ifNil:
>>>> Object>>ifNil:ifNotNil:
>>>> Object>>ifNotNil:
>>>> Object>>ifNotNil:ifNil:
>>>
>>There actually is a minor controversy here as the VisualWorks version
of these has the block for the ifNotNil: clauses take an optional
argument.
I have long preferred
isNil,
notNil,
and nonNil
so I'd rather have
isNil: a0block
notNil: a0block
nonNil: a1block
and some combinations, e.g.
isNil: is0block notNil: not0block
isNil: is0block nonNil: non1block
...
I don't expect to hear much agreeement,
just tossing it in for consideration.
The pattern generalizes to also cover
null, empty, blank, and value,
number, numeric, and integer,
zero, one, and infinity,
boolean, character, string, and symbol,
singular, element and collection.
All of which seem highly generic,
and reasonably useful, to me.
The optional arg thing is ok, and
could be extended to all the above forms,
but isn't as intention-revealing.
-Jim
_______________________________________________
ANSI-Smalltalk mailing list
ANSI-Smalltalk at lists.openskills.org
http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk
More information about the ANSI-Smalltalk
mailing list