I know why the following doesn't work:

     given $food {
         when Pizza | Lazagna { .eat }
         when .caloric_value > $doctors_orders { warn "no, no no" }
         # ...
     }

The expression in the second when clause is smart-matched against $food,
not tested for truth like an if. So currently the right way to code this is
something like

     DINER: given $food {
         when Pizza | Lazagna { .eat }
         if .caloric_value > $doctors_orders { warn "no, no no"; leave DINER }
         # ...
     }

(Or whatever the way to address labels is.)

I'm a little bothered that this is consistent but (to me, at least)
unintuitive. Testing methods on the topic is something people may want
to do often: is there a way to hide away the control logic? I'm tempted
to propose that when a ".method" is seen in the when expression, the
whole thing should become a terminal if. Inconsistent but possibly what
people want.

-- 
Gaal Yahas <[EMAIL PROTECTED]>
http://gaal.livejournal.com/

Reply via email to