[squeak-dev] #identityCaseOf:

Levente Uzonyi leves at caesar.elte.hu
Sun Mar 28 16:14:00 UTC 2021


On Sun, 28 Mar 2021, Tobias Pape wrote:

>
>
>> On 28. Mar 2021, at 16:03, Levente Uzonyi <leves at caesar.elte.hu> wrote:
>> 
>> On Sun, 28 Mar 2021, Tobias Pape wrote:
>> 
>>> Hi
>>> 
>>> 
>>>> On 28. Mar 2021, at 07:12, tim Rowledge <tim at rowledge.org> wrote:
>>>>> On 2021-03-27, at 11:47 AM, Thiede, Christoph <Christoph.Thiede at student.hpi.uni-potsdam.de> wrote:
>>>>> Hi all,
>>>>> the proposal is in the title. :-) Do you think we could need something like #identityCaseOf:[otherwise:], analogously to #caseOf:[otherwise:], on Object?
>>>> I would go with 'not'. I'm not a fan of #caseOf: either. Far too like C. Slippery slope to "oooh, let's have thing.ivar.ivar to be like structs."
>>> 
>>> Exactly.
>>> If you need something like that, there's either a missing polymorphic abstraction, or a few ifTrue:'s are sufficient.
>>> (as in the case of #update:
>>> 
>>> update: aSymbol
>>> 
>>> aSymbol == #foo ifTrue: [^ self knorz].
>>> aSymbol == #bar ifTrue: [^ self berfp].
>>> ^ false
>>> 
>>> I think this is sufficient.
>> 
>> Those ifTrue:'s quickly render your code unreadable or force you to extract chunks of your code into a separate method which can impair legibility.
>
>
> If you need more than a few of these, you're circumventing the actual method dispatch
> by dispatching on identity manually.
> Why making such nonsense easier?

So, it's the caseOf: vs no caseOf: discussion again. I'll just copy a link 
to Eliot's example here: 
http://forum.world.st/could-we-agree-to-remove-caseOf-and-caseOf-otherwise-tp3302475p3307627.html


Levente

>
> If you're building a bytecode interpreter, fine, but in that case, metaprogramming or code generation is not too far fetched either.
>
> -t
>
>> 
>>> 
>>> Otherwise, use an IdentityDictionary?
>> 
>> Ah, the good old Pharo-way of doing things. :D
>> 
>> All-in-all, it looks as though we're slipping into another caseOf: vs no-caseOf: discussion. Let's not do that.
>> 
>> 
>> Levente
>> 
>>> 
>>> Best regards
>>> 	-Tobias
>>


More information about the Squeak-dev mailing list