<div dir="ltr"><div dir="ltr"></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> For example, passing the object to the condition block (or even the result <br>
> block) could be useful:<br>
> <br>
> self someComplexExpression caseOf: {<br>
>       [ 1 ] -> [ self success ]<br>
>       [ :value | value odd ] -> [ :value | self processEvenValue: value - <br>
>       1 ].<br>
>       [ :value | true "it's even ] -> [ :value | self processEvenValue ] } </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> <br>
> There are two new things in the example:<br>
> - the value of self someComplexExpression is optionally passed to the <br>
> blocks. Yes, that could be done by creating a temporary variable. </blockquote><div><br></div><div><div>Here's the version using a temporary and existing API (with an added identity-check).</div><div><br></div><div>   result := self someComplexExpression.</div><div>   true caseOf:</div><div>      { [result=1] -> [self success].</div><div>      [result odd] -> [self processEvenValue: result-1].</div><div>      [ result == identityValue ] -> [self processSomethingElse ].</div><div>      [true] -> [self processEvenValue] }</div><div><br></div><div>"true caseOf:" is my sneaky way to improve its flexibility.  The suggested expansion of the API seems too dilute, not enough bang.</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The <br>
> compiler could do exactly that behind the scenes.<br>
> - when the value is passed to the matcher block, possibilities are greatly <br>
> extended. </blockquote><div><br></div><div>The evaluation is done before any of the caseOf tests, so is it really extended with more expressive power?  Or just a different syntax that moves the variable declaration from a temporary to the block arg?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">For example, it could even reproduce #identityCaseOf:<br>
> <br>
>       foo caseOf: {<br>
>               [ :o | o == #foo ] -> [ self foo ].<br>
>               [ :o | o == #bar ] -> [ self bar ] }<br>
> <br>
> The same thing could be done with the otherwise block too:<br>
> <br>
>       self foo<br>
>               caseOf: { ... }<br>
>               otherwise: [ :value | value ]<br>
> <br>
> <br>
> Levente<br>
> <br>
<br>
<br>
</blockquote></div></div>