$expression?;
to mean the same thing as the statement
$_ = $expression;
That is, any statement that ends with a '?;' instead of a ';'
evaluates in scalar context instead of void context and stores the
result as the topic '$_'. (I was going to suggest '?' intead of '?;',
but a quick review of the specs pointed out that this would be
ambiguous wrt the ? prefix operator.)
Is perl 6 powerful enough to enable this sort of thing with its
existing tools, or would the parser need to be altered?
--
Jonathan "Dataweaver" Lang
Prefix and postfix live in different places, so you can just use a
normal postfix operator:
sub postfix:<?> ($lhs) {
$CALLER::_ = $lhs;
}
42?;
say($_); # prints 42!
# This code is not futuristic. It already works with Pugs.
But you wanted a statement thingy. That would require that you modify
the Perl 6 grammar. Yes, you can do that with Perl 6.
--
korajn salutojn,
juerd waalboer: perl hacker <ju...@juerd.nl> <http://juerd.nl/sig>
convolution: ict solutions and consultancy <sa...@convolution.nl>
Ik vertrouw stemcomputers niet.
Zie <http://www.wijvertrouwenstemcomputersniet.nl/>.