Author: larry
Date: Mon Feb 4 12:43:51 2008
New Revision: 14498
Modified:
doc/trunk/design/syn/S03.pod
Log:
Major cleanup of the item/list assigment insanity.
Modified: doc/trunk/design/syn/S03.pod
==
--- doc/trunk/design/syn/S03.pod(original)
+++ doc/trunk/design/syn/S03.podMon Feb 4 12:43:51 2008
@@ -12,9 +12,9 @@
Maintainer: Larry Wall [EMAIL PROTECTED]
Date: 8 Mar 2004
- Last Modified: 27 Jan 2008
+ Last Modified: 4 Feb 2008
Number: 3
- Version: 128
+ Version: 129
=head1 Overview
@@ -2021,127 +2021,124 @@
=item *
-The list assignment operator now parses on the right like
+The list (array) assignment operator now parses on the right like
any other list operator, so you don't need parens on the right side of:
-@foo = 1,2,3;
+@foo = 1, 2, 3;
You do still need them on the left for
-($a,$b,$c) = 1,2,3;
+($a, $b, $c) = 1, 2, 3;
since assignment operators are tighter than comma to their left.
-=item *
-
-The scalar assignment operator still parses as it did before, so
+Don't care positions may be indicated by assigment to the C* token.
+A final C* throws away the rest of the list:
-loop ($a = 1, $b = 2; ; $a++, $b++) {...}
+($a, *, $c) = 1, 2, 3; # throw away the 2
+($a, $b, $c, *) = 1..42;# throw away 4..42
-still works fine. The syntactic distinction between scalar and list
-assignment is similar to the way PerlĀ 5 defines it, but has to be a
-little different because we can no longer decide on the basis of
-the sigil. The following forms are parsed as simple lvalues,
-and imply scalar assignment:
-
-$a # simple scalar variable
-$(ANY) # scalar dereference (including $$a)
-$::(ANY)# symbolic scalar dereference
-ANY[SIMPLE] # single simple subscript
-ANY{SIMPLE} # single simple subscript
-ANYx # single literal subscript
-
-Where SIMPLE is (recursively) defined as one of the forms above,
-plus the following forms:
-
-123 # single literal
-'x' # single literal
-$x# single literal
-qq/$x/ # single literal
-+TERM # any single term coerced to numeric
--TERM # any single term coerced to numeric
-~TERM # any single term coerced to string
-?TERM # any single term coerced to boolean
-!TERM # any single term coerced to boolean
-(SIMPLE)# any simple expression in circumfix parens
-
-Note that circumfix parens are considered simple only when used as
-part of a subscript. Putting parens around the entire lvalue still
-implies list context as in PerlĀ 5.
-
-We also include:
-
-OP SIMPLE
-SIMPLE OP
-SIMPLE OP SIMPLE
-
-where COP includes any standard scalar operators in the five
-precedence levels autoincrement, exponentiation, symbolic unary,
-multiplicative, and additive; but these are limited to standard
-operators that are known to return numbers, strings, or booleans.
-
-Operators that imply list operations are excluded: prefix C@,
-prefix C% and infix Cxx, for instance. Hyper operators are
-also excluded, but post-assignment forms such as CSIMPLE += SIMPLE
-are allowed.
-
-All other forms imply parsing as a list assignment, which may or may not
-result in a list assignment at run time. (See below.) However, this is
-exclusively a syntactic distinction, and no semantic or type information
-is used, since it influences subsequent parsing. In particular, even
-if a function is known to return a scalar value from its declaration,
-you must use C+ or C~ if you wish to force scalar parsing from
-within a subscript:
+List assignment offers the list on the right to each container on the
+left in turn, and each container may take one or more elements from the
+front of the list. If there are any elements left over, a warning is
+issued unless the list on the left ends with C* or the final iterator
+on the right is defined in terms of C*. Hence none of these warn:
-@a[foo()] = bar(); # foo() and bar() called in list context
-@a[+foo()] = bar(); # foo() and bar() called in item context
-
-But note that the first form still works fine if Cfoo() and Cbar()
-are item-returning functions that are not context sensitive. The difference
-in parsing is only an issue if Cbar() is followed by a comma or
-some such.
+($a, $b, $c, *) = 1..999;
+($a, $b, $c) = 1..*;
+($a, $b, $c) = 1 xx *;
+($a, $b, $c) = 1, 2, *;
-For non-simple lvalues, at run time, both sides are evaluated in list
-context, but if the left side results in a single non-list scalar,
-the right side is treated as a single scalar value, as if the right
-side had been evaluated in list context (which is indeed the case)
-but coerced into item context.
+This, however, warns you of information loss:
-If the left side returns a list, however, then regardless of whether
-the list