[squeak-dev] #identityCaseOf:

Balázs Kósi rebmekop at gmail.com
Sun Mar 28 10:39:34 UTC 2021


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> 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/ba8cdf18/attachment.html>


More information about the Squeak-dev mailing list