Definitive and Complete Perl 6 Operator List

47 views
Skip to first unread message

Andrew Savige

unread,
Apr 2, 2005, 2:42:40 AM4/2/05
to perl6-l...@perl.org
S03 does not seem to detail a complete list of all Perl 6 operators.
For example, it explicitly mentions += but does not mention -=

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:

http://groups-beta.google.com/group/perl.perl6.language/msg/cd1ca0a0c901d35f?hl=en&lr=&ie=UTF-8&rnum=1

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

Luke Palmer

unread,
Apr 2, 2005, 3:21:22 AM4/2/05
to Andrew Savige, perl6-l...@perl.org
Andrew Savige said:
> Is there a definitive, official, complete list of all Perl 6 operators,
> along with their precedence levels?

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

Brent 'Dax' Royal-Gordon

unread,
Apr 2, 2005, 4:49:24 AM4/2/05
to Luke Palmer, Andrew Savige, perl6-l...@perl.org
Luke Palmer <lu...@luqui.org> wrote:
> Andrew Savige said:
> > Is there a definitive, official, complete list of all Perl 6 operators,
> > along with their precedence levels?
>
> 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.

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."

Larry Wall

unread,
Apr 2, 2005, 12:20:57 PM4/2/05
to perl6-l...@perl.org
On Sat, Apr 02, 2005 at 01:49:24AM -0800, Brent 'Dax' Royal-Gordon wrote:
: 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.

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

Randal L. Schwartz

unread,
Apr 3, 2005, 11:49:38 AM4/3/05
to perl6-l...@perl.org
>>>>> "Larry" == Larry Wall <la...@wall.org> writes:

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!

Reply all
Reply to author
Forward
0 new messages