[Grace-core] Short-circuiting elseif

James Noble kjx at ecs.vuw.ac.nz
Mon Mar 19 03:20:31 PDT 2012


On 16/03/2012, at 13:29 PM, Thomas Kühne wrote:

> Michael Homer wrote:
>> Alternatively all tests could be in blocks for consistency
>> across a call, even though the first one is always guaranteed to
>> execute.

I think that _if_ we want to add elseif forms (elseif? elif?) then that may be the best option..

> One solution is not to support "elseif" but provide a method that takes a collection of condition-action associations as the first argument.

well there is the following frankly evil perversion of pattern matching

match (true)
 case { (C1) -> B1 }
 case { (C2) -> B2 }
 case { (C3) -> B3 }
 case { (C4) -> B4 }

which should be supported by the "new" pattern match design I'm yet to type up.
It relies on the condition Boolean expressions (Cn) being first-class patterns,
assuming Boolean <: Pattern  (i.e. that Booleans match themselves).

That design has a few of its own problems, most notably that 

 true || false   // Boolean, true
is rather different to 
 true | false    // Pattern that matches either true or false, but hopefully not a Boolean

but it does allow that evil formulation above

James


More information about the Grace-core mailing list