Larry wrote: > sub while (&test is rx/<expr>/, &body); > > or some such. That probably isn't sufficient to pick <expr> out of Perl's > grammar rather than the current lexical scope.
I love the idea, but the property name needs to be more expressive (and Huffmanly longer). Maybe: sub while (&test is specified(/<Perl.expr>/), &body); C<rx> is not ideal because it would also be very useful to be able to select between variants of a multimethod by matching a pattern against the *value* of an argument. That is: sub repeat is multi ($count is valued(/\d+/), &body) { body($_) for 1..$count; } rule et_cetera :w { forever | ad nauseum | etc | et cetera } sub repeat is multi ($desc is valued(/<et_cetera>/), &body) { body($_) for 1..Inf; } # and then... repeat 2 { print "cha" } repeat 'forever' { print "ha" } repeat $count { print "ha" } And, of course, the C<is valued> property would smart-match its value against the corrresponding argument, so one could also code optimized variants like: sub repeat is multi ($desc is valued(1), &body) { body(1); } sub repeat is multi ($desc is valued(0), &body) { } sub repeat is multi ($desc is valued(['A'..'F']), &body) { die "Can't repeat hexadecimally"; } Come to think of it, maybe the property name probably should be C<is when>. > I don't particularly like the old map and grep syntax. Recently someone suggested to me (sorry, whoever it was, my memory is still in anyother timezone) that, since C<given> returns a value: $val = given $digit { case [0..9] { $_ } case ['A'..'F'] { 10+ord($_)-ord('A') } default { undef } }; then maybe the other control structues should as well: @squares = map { $_**2 } @nums; @squares = for @nums { $_**2 }; Of course, this example is trivially done with a hyperoperation: @ squares = @nums ^** 2; But more complex examples could easily be constructed where even C<map> looks clunky and a list context C<for> would be a nice solution. It would also solve the problem of early escape: @smallsquares = for @nums { last if $_ > 10; $_**2 }; Damian