develooper Front page | perl.perl6.compiler | Postings from April 2006

Infix macro := reparsing the LHS?

Thread Next
Audrey Tang
April 19, 2006 07:11
Infix macro := reparsing the LHS?
Message ID:
Not sure if this is p6l or p6c... Fallback to the latter. :)

In this line:

   [Dog ::T $ ($x) where 1, *$, *@] := moose();

the left hand side is probably not a valid Perl 6 expression, yet
according to the current spec, it needs to be parsed implicitly as if a
:() is around it.

How does this work in practice? Is an infix macro allowed to change the
"is parsed" of its LHS? Should that trigger a reparse, or do we use
(potentially costly) prescanning?

A way out of this may be requiring :() on the LHS of :=, and treat it as
an infix macro that only changes how the RHS is parsed (which would be
trivial). Or, for symmetry, make := ordinary infix, and require both
side to be :() and \() respectively.

I agree that

    ($x, $y) := ($y, $x)

is clean (and featured in various places).  However, as long as there
are some Signature forms that isn't valid expression form, or would
triggered parse-time expression-form macros that wouldn't trigger in
Signature forms, I can't figure out how it would work.

The infix:<=> has no such problem because all valid lvalue expressions
are also valid rvalue expressions in Perl 6.


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About