Googling around, I found the Perl 6 Periodic Table of Operators
http://www.ozonehouse.com/mark/blog/code/PeriodicTable.html
(which I assume does not form part of the official Perl 6 docs)
and this November 1 2002 p6l post:
which is the closest I found to what I'm looking for.
Is there a definitive, official, complete list of all Perl 6 operators,
along with their precedence levels?
For example, this Perl 6 program:
my $i = 0;
$i ~^= 2;
Pugs currently rejects with:
pugs: cannot cast into a handle: VInt 2
Since ~^ is string xor, I guessed that ~^= would be allowed.
/-\
Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com
I believe that Kurt Gödel, in a corollary to his famous theorem, also
showed that "Any Perl 6 list is either indefinitive or incomplete".
Well, Synopsis 3 is the list you're looking for, but it's clearly not
all there. Take the table there to be your definitive list, and mail
questions about its accuracy here. I'll do my best to keep up with you
and maintain it.
> For example, this Perl 6 program:
>
> my $i = 0;
> $i ~^= 2;
>
> Pugs currently rejects with:
>
> pugs: cannot cast into a handle: VInt 2
>
> Since ~^ is string xor, I guessed that ~^= would be allowed.
Yeah, any binary operator that takes two Xs to an X should have an =
form. It might even be that any operator which takes an X on its left
hand side and maps it to an X should have an = form, but it's probably
best to keep it at the former requirement for now.
Luke
Uploaded so it doesn't get word-wrapped and thus rendered useless to tools:
<http://www.brentdax.com/junk/perl6/perl6op.txt>
I've included assignment forms of all operators in the exponentiation,
multiplicative, additive, junctive, and tight logical levels; this may
be overkill or underkill. I've not included hyper forms of these
operators, as I figure they're handled by metaoperators. Also, the
"terms" level isn't really exhaustive.
In any case, let me know if anything's missing--or for that matter if
anything's there that shouldn't be.
--
Brent 'Dax' Royal-Gordon <br...@brentdax.com>
Perl and Parrot hacker
"I used to have a life, but I liked mail-reading so much better."
I would say that assignment operators are also metaoperators. They're
just a bit picky about which precedence levels they metastasize.
In other words, if someone adds an appropriate binary operator, it
would automatically get the assignment meta-operator. But not if
it's a chaining binary, non-chaining binary, or assignment operator.
(We could define the levels that it *does* work on, but then it doesn't
work on user-defined precedence levels by default. Alternatively,
we could develop a profile apart from precedence levels for operators
that are omitted, such as ones that return boolean values, or that create
new objects, or that mutate their left argument already.)
: In any case, let me know if anything's missing--or for that matter if
: anything's there that shouldn't be.
Seems to be missing:
infix:<?&>
infix:<?|>.
infix:<?^>.
The shifts are all X< rather than X<< to avoid confusion with Texas Quotes.
Oh, and we recently moved => to assignment precedence so it would
more naturally be right associative, and to keep the non-chaining
binaries consistently non-associative. Also lets you say:
key => $x ?? $y :: $z;
plus it moves it closer to the comma that it used to be in Perl 5.
Larry
Larry> The shifts are all X< rather than X<< to avoid confusion with Texas Quotes.
I've been staring too much at POD lately. I saw both of those as very
broken pod-start marks. :)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<mer...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!