Author: larry
Date: Sat Jun 2 14:45:43 2007
New Revision: 14414
Modified:
doc/trunk/design/syn/S03.pod
Log:
First installment of filling out descriptions of operator semantics.
Modified: doc/trunk/design/syn/S03.pod
==
--- doc/trunk/design/syn/S03.pod(original)
+++ doc/trunk/design/syn/S03.podSat Jun 2 14:45:43 2007
@@ -97,21 +97,40 @@
=item *
+Heredoc
+
+qq:to/END/
+Dear $recipient:
+Thanks!
+Sincerely,
+$me
+END
+
+=item *
+
Array composer
[1,2,3]
+Provides list context inside.
+
=item *
Hash composer
{ a = 42 }
+Inside must be a list of pairs, otherwise you must use Chash()
+or C%() instead.
+
=item *
Closure
-{...}
+{ ... }
+
+When found where a statement is expected, executes immediately. Othewise
+always defers evaluation of the inside scope.
=item *
@@ -119,6 +138,8 @@
\(@a,$b,%c)
+An abstraction representing an argument list that doesn't yet know its context.
+
=item *
Sigiled variables
@@ -128,7 +149,7 @@
%z
$^a
$?FILE
-@@multidim
+@@slice
func
div:(Int, Int -- Int)
@@ -247,6 +268,9 @@
$obj.::Class::meth
$obj.Class::meth# same thing, assuming Class is predeclared
+As in Perl 5, tells the dispatcher which class to start searching from,
+not the exact method to call.
+
=item *
Mutating method call
@@ -286,7 +310,7 @@
Dotted postfix form of any other prefix operator
-$x.'++' # prefix:++($x), fallback to postfix:++
+$x.:++ # prefix:++($x)
=back
@@ -396,79 +420,109 @@
prefix:?, boolean context
-?
+?$x
+Evaluates the expression as a boolean and returns CTrue if expression
+is true or CFalse otherwise.
See true below for a low-precedence alternative.
=item *
prefix:!, boolean negation
-!
+!$x
+Returns the opposite of what C? would.
See not below for a low-precedence alternative.
=item *
prefix:+, numeric context
-+
++$x
+
+Unlike in Perl 5, where C+ is a no-op, this operator coerces
+to numeric context in Perl 6. (It coerces only the value, not the
+original variable.) The narrowest appropriate type of CInt, CNum,
+or CComplex will be returned. A string containing two integers
+separated by a C/ will be returned as a CRat. Exponential notation
+and radix notations are recognized.
=item *
prefix:-, numeric negation
--
+-$x
+
+Coerces to numeric and returns the negation of the resulting number.
=item *
prefix:~, string context
-~
+~$x
+
+Coerces the value to a string. (It only coerces the value, not the
+original variable.)
=item *
prefix:|, flatten object into arglist
-|
+| $capture
+
+Interpolates the contents of the CCapture (or CCapture-like) value
+into the current argument list as if they had been specified literally.
=item *
prefix:+^, numeric bitwise negation
-+^
++^$x
+
+Coerces to numeric and then does bitwise negation on the number.
=item *
prefix:~^, string bitwise negation
-~^
+~^$x
+Coerces to string buffer and then does bitwise negation on each element.
=item *
prefix:?^, boolean bitwise negation
-?^
+?^$x
+
+Coerces to boolean and then flips the bit. (Same as C!.)
=item *
prefix:\, Capture constructor
-\
+\$x
+[EMAIL PROTECTED]
+\%x
+\($invocant: $pos1, $pos2, :named($arg))
+
+Defers the contextualization of its argument or arguments till it is
+bound into some other context.
=item *
prefix:^, upto operator
-^
+^$limit
-Constructs a range or locates a metaclass. See L/Range semantics.
+Constructs a range of C0..^$limit or locates a metaclass as a shortcut
+for C$limit.HOW. See L/Range semantics.
=item *
prefix:=, iterate iterator
-=
+=$iterator
Unary C= reads lines from a filehandle or filename, or
iterates an iterator, or in general causes a scalar to explode its guts
@@ -491,7 +545,9 @@
infix:*
-*
+$x*$y
+
+Multiplication, resulting in wider type of the two.
=item *
@@ -499,7 +555,8 @@
$numerator / $denominator
-Converts both operands to CNum and does division returning CNum.
+If either operand is of CNum type,
+converts both operands to CNum and does division returning CNum.
If the denominator is zero, returns either C+Inf, CNaN, or C-Inf
as the numerator is positive, zero, or negative. (This is construed
as the best default in light of the operator's possible use within
@@ -507,6 +564,11 @@
on an individual scalar division, you can always check the denominator
yourself.)
+If both operands are of integer type, you still get a CNum, but the
+CNum type is allowed to do the division lazily; internally it may
+store a CRat until the time a value is called for. If converted
+to CRat directly no division ever need be done.
+
=item *
infix:div, generic