2009/7/20 Vincent Pit <perl@profvince.com>: > Just as the title says, this patch makes given() blocks return values, > with the following rules : > - if an explicit break is encountered, return an empty list ; > - if a when/default clause is true (and doesn't contain an explicit > break), return the value of the last evaluated expression of the block ; > - if all conditions were false, return the value of the last evaluated > expression of the block. > I've also made when/default not return anything (unlike 'if' and > 'unless' which returns the value of the condition). > > Regarding the implementation, I added 'switch' to the 'term' rule. This > made the YYLAST value increase a lot : > > -#define YYLAST 2061 > +#define YYLAST 2446 > > I'm not a bison specialist, so I'd like to know if there isn't some kind > of heavy penalty hidden there. > > Then I made scalar()/list() correctly propagate into given/when OPs. > There's very little run-time changes. pp_leavegiven() was just taught to > correctly set the stack pointer. It also mimics pp_leavetry() to make > sure that all the stack elements are correctly tainted/mortalized. This is extremely neat. However by looking at the perly.y part of the patch (I haven't looked at the other ones yet) I see that you add switch as a derivation for the term rule, but switch can begin with a label. And terms don't. I'd rather have a new rule switch : label given; and add given to term.Thread Previous | Thread Next