On Fri, Jun 20, 2008 at 12:06:31PM -0400, Ronald J Kimball wrote: > (Note that return can be usefully used as an expression: > my $foo = $bar ? return : 'baz'; > Odd, but it works.) But then people start writing code that looks like this: $basket->calculate() or return $self->emit("Could not recalculate", 'error') if $basket->complete(); and I go http://www.flickr.com/photos/twoshortplanks/28698637/ (sadly I no longer have the other example of code from the same author, that mixed declaration, conditional initialisation and control flow in one statement. But actually, I don't think that he was using ternaries in either) On Fri, Jun 20, 2008 at 06:29:45PM +0200, Rafael Garcia-Suarez wrote: > return is technically parsed as a list operator (LSTOP). > That enables using it in compound expressions. > > Note that this syntax works also for other control flow statements : > > $ perl -wle '$i=3;while(1){print($i--||last)}' > 3 > 2 > 1 > > I don't really see a reason to change it. Ah. Makes sense. I guess I can reject my own bug. Nicholas ClarkThread Previous | Thread Next