[squeak-dev] Extending the functionality of caseOf: (was: #identityCaseOf:)
Thiede, Christoph
Christoph.Thiede at student.hpi.uni-potsdam.de
Wed Apr 7 15:56:19 UTC 2021
I like these proposals, too. At the moment, it is very hard to implement any change in #caseOf:[otherwise:] because the Compiler optimization has to be adjusted. We should make this optimization selective analogously to #ifTrue:, #whileTrue:. etc., so that all the fancy examples you have mentioned before will be compiled as regular message sends unless someone feels like optimizing them.
What do you think? :-)
<http://www.hpi.de/>
Best,
Christoph
________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von David T. Lewis <lewis at mail.msen.com>
Gesendet: Montag, 29. März 2021 01:32:26
An: ma.chris.m at gmail.com; The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] Extending the functionality of caseOf: (was: #identityCaseOf:)
On Sun, Mar 28, 2021 at 05:26:42PM -0500, Chris Muller wrote:
>
> Here's the version using a temporary and existing API (with an added
> identity-check).
>
> result := self someComplexExpression.
> true caseOf:
> { [result=1] -> [self success].
> [result odd] -> [self processEvenValue: result-1].
> [ result == identityValue ] -> [self processSomethingElse ].
> [true] -> [self processEvenValue] }
>
> "true caseOf:" is my sneaky way to improve its flexibility. The suggested
> expansion of the API seems too dilute, not enough bang.
>
I really like the true caseOf: approach. It seems obvious now that you
point it out, but I never would have thought of it. Thanks :-)
Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210407/e1d3cfdd/attachment.html>
More information about the Squeak-dev
mailing list
|