> On Monday, March 31, 2003, at 12:30 PM, Paul wrote: > > I started to suggest this myself, then realized that you might not want > > it to return at all if the value is false. > > Yes, exactly: > > sub foo(...args...) { > # We first attempt to get our return value the easy way. > # If successful (the resulting value is defined and true), > # just return that value. > > my $x = &baz(...args...); > return $x if $x; > > # Still here? OK, then... we've got a lot more work > # to do before we can return a reasonable value > > ... > } > > I'm looking for a Perl6 way to say that oft-repeated, oft-chained > two-line snippet up there without declaring the temporary variable. > Using C<given> or C<when>, maybe?
The idea of a pronoun, something other than $_, has occasionally crossed my mind. I haven't given it any real thought, but perhaps this is the time. return it if &baz(...args...); Something that represents the "last evaluated expression"... or something similar that is sufficiently DWIMmy. I'm trying to stay away from punctuation variables for fear of repeating Perl 5's mistakes. C<it> might be just the thing... now all that has to be done is come up with semantics. And decide whether it's a good idea. Luke