Author: larry
Date: Mon Mar 17 10:37:26 2008
New Revision: 14522
Modified:
doc/trunk/design/syn/S02.pod
doc/trunk/design/syn/S03.pod
doc/trunk/design/syn/S04.pod
doc/trunk/design/syn/S05.pod
doc/trunk/design/syn/S06.pod
doc/trunk/design/syn/S09.pod
Log:
Various typos and suggestions from (spinclad, nick, daniel)++
Clarification of semantics of list assignment, batch iteration
ss:g/scalar context/item context/
Modified: doc/trunk/design/syn/S02.pod
==
--- doc/trunk/design/syn/S02.pod(original)
+++ doc/trunk/design/syn/S02.podMon Mar 17 10:37:26 2008
@@ -12,7 +12,7 @@
Maintainer: Larry Wall [EMAIL PROTECTED]
Date: 10 Aug 2004
- Last Modified: 15 Mar 2008
+ Last Modified: 17 Mar 2008
Number: 2
Version: 130
@@ -1317,8 +1317,11 @@
Sigils are now invariant. C$ always means a scalar variable, C@
an array variable, and C% a hash variable, even when subscripting.
-Variables such as C@array and C%hash in scalar context simply
-return themselves as CArray and CHash objects.
+In item context, variables such as C@array and C%hash simply
+return themselves as CArray and CHash objects. (Item context was
+formerly known as scalar context, but we now reserve the scalar
+notion for talking about variables rather than contexts, much as
+arrays are disassociated from list context.)
=item *
@@ -1364,35 +1367,39 @@
The context in which a subscript is evaluated is no longer controlled
by the sigil either. Subscripts are always evaluated in list context.
-If you need to force inner context to scalar, we now have convenient
+If you need to force inner context to item (scalar), we now have convenient
single-character context specifiers such as + for numbers and ~ for strings:
-$x= g(); # scalar context and g()
+$x= g(); # item context for g()
@x[f()] = g(); # list context for f() and g()
-@x[f()] = +g(); # list context for f(), scalar context for g()
-@x[+f()] = g(); # scalar context for f(), list context for g()
+@x[f()] = +g(); # list context for f(), numeric item context for
g()
+@x[+f()] = g(); # numeric item context for f(), list context for
g()
@x[f()] = @y[g()]; # list context for f() and g()
@x[f()] = [EMAIL PROTECTED]()]; # list context for f() and g()
-@x[+f()] = @y[g()]; # scalar context for f(), list context for g()
-@x[f()] = @y[+g()]; # list context for f(), scalar context for g()
+@x[+f()] = @y[g()]; # numeric item context for f(), list context for
g()
+@x[f()] = @y[+g()]; # list context for f(), numeric item context for
g()
-Sigils used as list prefix operators may also be used to force context:
+%x{~f()} = %y{g()}; # string item context for f(), list context for g()
+%x{f()} = %y{~g()}; # list context for f(), string item context for g()
-@x = $ g(); # scalar context for g()
-$x = @ g(); # list context for g()
-$x = % g(); # list context for g() (and coercion to hash)
+Sigils used either as functions or as list prefix operators also
+force context, so these also work:
-These may also be used in functional form:
+@x[$(g())] # item context for g()
+@x[$ g()] # item context for g()
+%x{$(g())} # item context for g()
+%x{$ g()} # item context for g()
-@x = $(g()); # scalar context for g()
-$x = @(g()); # list context for g()
-$x = %(g()); # list context for g() (and coercion to hash)
+But note that these don't do the same thing:
+
+@x[$g()] # call function in $g
+%x{$g()} # call function in $g
=item *
There is a need to distinguish list assignment from list binding.
-List assignment works exactly as it does in PerlĀ 5, copying the
+List assignment works much like it does in PerlĀ 5, copying the
values. There's a new C:= binding operator that lets you bind
names to Array and Hash objects without copying, in the same way
as subroutine arguments are bound to formal parameters. See S06
@@ -1429,7 +1436,7 @@
hash, all named arguments; into a scalar, its invocant.
All prefix sigil operators accept one positional argument, evaluated in
-scalar context as a rvalue. They can interpolate in strings if called with
+item context as a rvalue. They can interpolate in strings if called with
parentheses. The special syntax form C$() translates into C$( $/ )
to operate on the current match object; the same applies to C@() and C%().
@@ -1454,7 +1461,7 @@
be used within other signatures to apply additional type constraints.
When applied to a CCapture argument, the signature allows you to
take the types of the capture's arguments from CMySig, but declare
-the (untyped) variable names yourself via an addition signature
+the (untyped) variable