<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
Why can't we apply the "hybrid" solution from #ifNotNil: here? Afaik the argument is inlined if it's a block, otherwise not. Specifying something inefficient is not recommended, but possible.<span id="OutlookSignature"></span><br>
<br>
<br>
</div>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
Von: Levente Uzonyi<br>
</div>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
Gesendet: Donnerstag, 15. August, 13:32<br>
</div>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
Betreff: Re: [squeak-dev] Question about #caseOf:otherwise:<br>
</div>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
An: The general-purpose Squeak developers list<br>
<br>
<br>
</div>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
On Thu, 15 Aug 2019, Thiede, Christoph wrote: > > Sounds very interesting :) > > > In the past I have been writing the following instead: > > > true caseOf: { > >     [aNumber isEven] -> ['That is an even number.']. > >     [aNumber isOdd] -> ['That is an odd
 number.'].  > > }. > > > but your code is much more beautiful :) > > I think both variants have a contrary semantic, but on the other hand it just reads intuitive: > > > aNumber caseOf: { >    [42] -> ['That is correct.']. >    [:n | n even] -> ['That is an
 even number.']. >    [:n | n odd] -> ['That is an odd number.']. > }. > > > This would also require some changes to the Parser. If your examples compiles, I would also expect the following to run: > > aNumber caseOf: { >    #even -> ['That is an even number.'].
 >    #odd -> ['That is an odd number.']. > }. While you could expect that to compile, the Parser is strict about the format, because everything (blocks, associations, the array) will be inlined, so no objects will be created for them. Without inlining, such
 construct would not be viable performance-wise. Levente > > Best, > Christoph > > _________________________________________________________________________________________________________________________________________________________________________________________________________________________________
 > Von: Squeak-dev im Auftrag von Taeumel, Marcel > Gesendet: Donnerstag, 15. August 2019 10:32:07 > An: gettimothy via Squeak-dev > Betreff: [squeak-dev] Question about #caseOf:otherwise:   > Hi all! > > Why isn't the following example possible? > > aNumber
 caseOf: { >    [:n | n even] -> ['That is an even number.']. >    [:n | n odd] -> ['That is an odd number.']. > }. > > That is, why is the check "assoc key value = self" not configurable as "(x := assoc key cull: self) == true or: [x = self]"? :-) > > ...
 maybe it is a good thing that case-of statements in Smalltalk are not that powerful? > > Best, > Marcel > ><br>
<br>
</div>
</body>
</html>