Author: lwall
Date: 2009-01-29 21:32:51 +0100 (Thu, 29 Jan 2009)
New Revision: 25113
Modified:
docs/Perl6/Spec/S03-operators.pod
src/perl6/STD.pm
Log:
[STD, S03] slaughter of the LTM metatokens
STD now runs considerably faster
Freed from LTM, metaoperators may now be nested arbitrarily deep
new [op] notation for infix functions
Modified: docs/Perl6/Spec/S03-operators.pod
===
--- docs/Perl6/Spec/S03-operators.pod 2009-01-29 15:35:07 UTC (rev 25112)
+++ docs/Perl6/Spec/S03-operators.pod 2009-01-29 20:32:51 UTC (rev 25113)
@@ -12,9 +12,9 @@
Maintainer: Larry Wall la...@wall.org
Date: 8 Mar 2004
- Last Modified: 27 Jan 2009
+ Last Modified: 29 Jan 2009
Number: 3
- Version: 150
+ Version: 151
=head1 Overview
@@ -49,7 +49,7 @@
R Item assignment = := ::= = += -= **= xx= .=
L Loose unary true not :by(2)
X Comma operator, p5= :
-X List infixZ minmax X X~X X*X XeqvX ...
+X List infixZ minmax X X~ X* Xeqv ...
R List prefix print push say die map substr ... [+] [*] any $ @
X Loose and and andthen
X Loose or or xor orelse
@@ -1697,9 +1697,9 @@
Cross hyperoperators
-@files X~X '.' X~X @extensions
-1..10 X*X 1..10
-@x XeqvX @y
+@files X~ '.' X~ @extensions
+1..10 X* 1..10
+@x Xeqv @y
etc.
See L/Cross operators.
@@ -3507,21 +3507,24 @@
The precedence of any negated operator is the same as the base operator.
+The operator
+
+!%
+
+is specially allowed for testing even divisibility by an integer.
+
Note that logical operators such as C|| and C^^ do not return a Bool,
but rather one of the operands.
=head2 Reversed comparison operators
-Any infix comparison operator returning type COrder may be transformed into
its reversed sense
-by prefixing with C-.
+Any infix operator may be called with its two arguments reversed
+by prefixing with CR. For instance, to do reversed comparisons:
--cmp
--leg
--=
+Rcmp
+Rleg
+R=
-To avoid confusion with the C-= operator, you may not modify
-any operator already beginning with C=.
-
The precedence of any reversed operator is the same as the base operator.
=head2 Hyper operators
@@ -3964,22 +3967,22 @@
=head2 Cross operators
The final metaoperator is the cross metaoperator. It is formed syntactically
-by placing an infix operator between two CX characters. It applies the
+by placing an infix operator after the CX character. It applies the
modified operator across all groupings of its list arguments as returned
by the ordinary C infix:X operator. All
cross operators are of list infix precedence, and are list associative.
The string concatenating form is:
-a b X~X 1 2 # 'a1', 'a2', 'b1', 'b2'
+a b X~ 1 2 # 'a1', 'a2', 'b1', 'b2'
-The CX~X operator desugars to something like:
+The CX~ operator desugars to something like:
-[~]«( a b X,X 1 2 ) # 'a1', 'a2', 'b1', 'b2'
+[~]«( a b X, 1 2 ) # 'a1', 'a2', 'b1', 'b2'
-The list concatenating form, CX,X, when used like this:
+The list concatenating form, CX,, when used like this:
-a b X,X 1,2 X,X x y
+a b X, 1,2 X, x y
produces
@@ -3998,15 +4001,15 @@
For the general form, any existing, non-mutating infix operator
may be used.
-1,2 X*X 3,4 # 3,4,6,8
+1,2 X* 3,4 # 3,4,6,8
(Note that C == and C == are considered mutating, as well as
all assignment operators.)
If the underlying operator is non-associating, so is the metaoperator:
-@a XcmpX @b XcmpX @c # ILLEGAL
-@a XeqX @b XeqX @c # ok
+@a Xcmp @b Xcmp @c # ILLEGAL
+@a Xeq @b Xeq @c # ok
In fact, though the CX operators are all list associative
syntactically, the underlying operator is always applied with its
@@ -4019,44 +4022,37 @@
=head2 Nesting of metaoperators
-In order to match operators by the longest-token rule, the
-compiler pregenerates various metaforms based on existing operators.
-Unfortunately, with nesting metaoperators there are an infinite number
-of metaforms, so we arbitrarily say that no metacircumfix form is
-pregenerated that uses the same grammatical category more than once.
-Therefore forms like C[+=] and C»!===« and CX*X= are generated,
-but not forms like C»X*X« or CX«*»X or C +== .
-You do get C[X*X],
-though, because reduction is prefix_circumfix_meta_operator while
-cross operators are infix_circumfix_meta_operator.
+Constructs containing metaoperators are considered metatokens,
+by which we mean that they are not subject to ordinary longest-token
+matching rules, although their components are. Like ordinary
+tokens, however, metaoperators do not allow whitespace between
+their subparts.
-This use-each-category-once limitation is not a great hardship since
-you can define your own infix operators. Suppose you say
+Any