[squeak-dev] #identityCaseOf:

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Sun Mar 28 11:47:52 UTC 2021


Hi Balázs,

<http://www.hpi.de/>

absolutely right. Thanks for your hint, I just committed the change to SimulationStudio. [1]

Best,
Christoph

[1] https://github.com/LinqLover/SimulationStudio/pull/23
________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Balázs Kósi <rebmekop at gmail.com>
Gesendet: Sonntag, 28. März 2021 12:39:34
An: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] #identityCaseOf:

Hi Christoph,

Just a side note concerning the code you linked: Is checking error for nil in line 15 necessary?

Balázs

On Sat, Mar 27, 2021 at 7:47 PM Thiede, Christoph <Christoph.Thiede at student.hpi.uni-potsdam.de<mailto: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?


Here is my motivation: I very often use #caseOf:[otherwise:] to eliminate nested if blocks (for one of many examples, take a look at PreferenceBrowserMorph >> #keyPressed:). In one recent situation [1], however, I confused equality and identity (I have to admit that this is a common error of mines) so I had to convert my beautiful #caseOf: statement back to a boring list of if checks. I wonder whether we could - or should - introduce something like #identityCaseOf:otherwise: (names subjected to discussion) for such situations?


Historically, I guess this has not been built because #caseOf: has probably been inspired by the switch/select/case statement of other languages, which usually only accept constant case values. But in Smalltalk, luckily, we do not have this restriction, thus I'm wondering whether there is any reason to have #caseOf: but not #identityCaseOf:. Looking forward to your opinions! :-)


Best,

Christoph

<http://www.hpi.de/>

[1] https://github.com/LinqLover/SimulationStudio/commit/ddf0ef3e21c63a2fd9b08703c8e9ff213b7b6b0b

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210328/de7e32a6/attachment.html>


More information about the Squeak-dev mailing list