On Tue, Aug 28, 2012 at 06:52:35PM -0400, David Golden wrote: > On Tue, Aug 28, 2012 at 5:06 PM, Jesse Luehrs <doy@tozt.net> wrote: > > > I think people will have fewer reservations about accepting weird > > special cases like this for a keyword-based control structure > > (especially considering the precedent set by while (<>), etc) than for > > an infix operator (since it will be a weird special case either way - > > "why can i do '$foo ~~ 1', but not '$a = 1; $foo ~~ $a'?". > > > > > The opportunity for confusion exists either way. My suggestion is to > change *one* thing -- smartmatch -- instead of *two* things -- smartmatch > and when. > > Then all people have to know/relearn is the smartmatch table, not the > smartmatch table *and* the special case rules for when. But this *is* a change to when, that's what I'm saying. From perlsyn: Exactly what the EXPR argument to "when" does is hard to describe precisely, but in general, it tries to guess what you want done. Sometimes it is interpreted as "$_ ~~ EXPR", and sometimes it does not. It also behaves differently when lexically enclosed by a "given" block than it does when dynamically enclosed by a "foreach" loop. The rules are far too difficult to understand to be described here. See "Experimental Details on given and when" later on. For instance, currently "when ($a && $b)" means "when ($_ ~~ $a && $_ ~~ $b)". -doyThread Previous | Thread Next