[squeak-dev] Compiler pedantic about ifNotNil: argument

Levente Uzonyi leves at elte.hu
Sun Oct 10 17:36:06 UTC 2010


On Sun, 10 Oct 2010, Igor Stasenko wrote:

> 2010/10/10 Levente Uzonyi <leves at elte.hu>:
>> On Sun, 10 Oct 2010, Igor Stasenko wrote:
>>
>>> On 10 October 2010 17:34, Randal L. Schwartz <merlyn at stonehenge.com>
>>> wrote:
>>>>>>>>>
>>>>>>>>> "Igor" == Igor Stasenko <siguctua at gmail.com> writes:
>>>>
>>>> Igor> i am also missing:
>>>>
>>>> Igor> someThing ifTrue: 1 ifFalse: 0
>>>>
>>>> Down that path lies ambiguity though.
>>>>
>>>> If you had
>>>>
>>>>  actionSymbol := aBoolean ifTrue: #doThis else: #doThat.
>>>>
>>>> do you want the symbol assigned, or performed?
>>>>
>>>> Please don't add so much dwimmery here.  I like it that Smalltalk is
>>>> fairly strict with these basic forms.
>>>
>>> what dwimmery you talking about?
>>>
>>> b :=  [ 15 ].
>>> a :=  [ 16 ].
>>>
>>> true ifTrue: a ifFalse: b
>>> 16
>>>
>>> as well as:
>>>
>>> b :=  15 .
>>> a :=  16 .
>>>
>>> true ifTrue: a ifFalse: b
>>> 16
>>>
>>> works well.
>>>
>>>
>>> In this way,
>>>
>>> answer := process ifNotNil: #terminate.
>>>
>>> should be equivalent to:
>>>
>>> answer := process notNil ifTrue: #terminate
>>>
>>> but not to:
>>>
>>> answer := process notNil ifTrue: [ process terminate ].
>>
>> How would you implement #ifNotNil: to reflect this? Would you dispatch on
>> the type of the argument?
>>
>
> true ifTrue sends #value to its argument. What is wrong with such kind
> of dispatch?

That kind of dispatch is ok, but would you really add this method to 
every object?

Object >> cull: anObject

 	^self


Levente

>
> But okay.. i see that
>
>  foo ifNotNil: #bar
>
> is more userful in a form, when it leads to
>
> foo perform: #bar
>
> rather than just returning #bar.
>
>
>>
>> Levente
>>
>>>
>>>
>>>>
>>>> --
>>>> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
>>>> 0095
>>>> <merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
>>>> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
>>>> See http://methodsandmessages.posterous.com/ for Smalltalk discussion
>>>>
>>>
>>>
>>>
>>> --
>>> Best regards,
>>> Igor Stasenko AKA sig.
>>>
>>
>>
>>
>>
>
>
>
> -- 
> Best regards,
> Igor Stasenko AKA sig.
>
>


More information about the Squeak-dev mailing list