Author: larry
Date: Wed Feb 28 07:55:51 2007
New Revision: 14306
Modified:
doc/trunk/design/syn/S02.pod
doc/trunk/design/syn/S05.pod
doc/trunk/design/syn/S06.pod
Log:
The old "is context is rw" is now written "is context<rw>".
The old "is context(Scalar)" is gone; use a macro.
Fixed some off-by-one errors in the S05 ascii art.
Modified: doc/trunk/design/syn/S02.pod
==============================================================================
--- doc/trunk/design/syn/S02.pod (original)
+++ doc/trunk/design/syn/S02.pod Wed Feb 28 07:55:51 2007
@@ -12,9 +12,9 @@
Maintainer: Larry Wall <[EMAIL PROTECTED]>
Date: 10 Aug 2004
- Last Modified: 26 Feb 2007
+ Last Modified: 28 Feb 2007
Number: 2
- Version: 90
+ Version: 91
This document summarizes Apocalypse 2, which covers small-scale
lexical items and typological issues. (These Synopses also contain
@@ -1503,11 +1503,12 @@
failure.
Any lexical declared with the C<is context> trait is by default
-considered readonly outside the current lexical scope. You may add
-C<is rw> to allow called routines to modify your value. C<$_>,
-C<$!>, and C<$/> are C<rw> by default. In any event, your lexical
-scope can always access the variable as if it were an ordinary C<my>;
-the restriction on writing applies only to called subroutines.
+considered readonly outside the current lexical scope. You may
+add a trait argument of C<< <rw> >> to allow called routines to
+modify your value. C<$_>, C<$!>, and C<$/> are C<< context<rw> >>
+by default. In any event, your lexical scope can always access the
+variable as if it were an ordinary C<my>; the restriction on writing
+applies only to called subroutines.
=item *
Modified: doc/trunk/design/syn/S05.pod
==============================================================================
--- doc/trunk/design/syn/S05.pod (original)
+++ doc/trunk/design/syn/S05.pod Wed Feb 28 07:55:51 2007
@@ -1965,7 +1965,7 @@
# | subpattern subpattern |
# | __/\__ __/\__ |
# | | | | | |
- ms/ (I am the (walrus), ( khoo )**{2} kachoo) /;
+ ms/ (I am the (walrus), ( khoo )**{2} kachoo) /;
=item *
@@ -1996,7 +1996,7 @@
# | subpat-B subpat-C |
# | __/\__ __/\__ |
# | | | | | |
- ms/ (I am the (walrus), ( khoo )**{2} kachoo) /;
+ ms/ (I am the (walrus), ( khoo )**{2} kachoo) /;
then the C<Match> objects representing the matches made by I<subpat-B>
and I<subpat-C> would be successively pushed onto the array inside I<subpat-
@@ -2062,7 +2062,7 @@
=item *
-This behavior is quite different to PerlĀ 5 semantics:
+This behavior is quite different from PerlĀ 5 semantics:
# Perl 5...
#
@@ -2222,7 +2222,7 @@
=item *
In particular, the index of capturing parentheses restarts after each
-C<|>. Hence:
+C<|> or C<||> (but not after each C<&> or C<&&>). Hence:
# $0 $1 $2 $3 $4 $5
$tune_up = rx/ (don't) (ray) (me) (for) (solar tea), (d'oh!)
@@ -2282,7 +2282,7 @@
# : $/<ident> : $/[0]<ident> : :
# : __^__ : __^__ : :
# : | | : | | : :
- ms/ <ident> \: ( known as <ident> previously ) /
+ ms/ <ident> \: ( known as <ident> previously ) /
=back
@@ -2301,7 +2301,7 @@
# $<ident> $0<ident>
# __^__ __^__
# | | | |
- ms/ <ident> \: ( known as <ident> previously ) /
+ ms/ <ident> \: ( known as <ident> previously ) /
=item *
@@ -2409,10 +2409,10 @@
If a named scalar alias is applied to a set of I<capturing> parens:
- # ______/capturing parens\_____
- # | |
- # | |
- ms/ $<key>:=( (<[A..E]>) (\d**{3..6}) (X?) ) /;
+ # ______/capturing parens\______
+ # | |
+ # | |
+ ms/ $<key>:=( (<[A..E]>) (\d**{3..6}) (X?) ) /;
then the outer capturing parens no longer capture into the array of
C<$/> as unaliased parens would. Instead the aliased parens capture
@@ -2467,10 +2467,10 @@
If a named scalar alias is applied to a set of I<non-capturing> brackets:
- # ___/non-capturing brackets\__
- # | |
- # | |
- ms/ $<key>:=[ (<[A..E]>) (\d**{3..6}) (X?) ] /;
+ # ___/non-capturing brackets\___
+ # | |
+ # | |
+ ms/ $<key>:=[ (<[A..E]>) (\d**{3..6}) (X?) ] /;
then the corresponding C<< $/<key> >> Match object contains only the string
matched by the non-capturing brackets.
@@ -2580,28 +2580,28 @@
# Perl 5...
# $1
- # _____________/\______________
- # | $2 $3 $4 |
- # | __/\___ ____/\____ /\ |
- # | | | | | | | |
- m/ ( (<[A..E]>) (\d**{3..6}) (X?) ) /;
+ # _____________/\___________
+ # | $2 $3 $4 |
+ # | __/\___ __/\___ /\ |
+ # | | | | | | | |
+ m/ ( ( [A-E] ) (\d{3,6}) (X?) ) /x;
# Perl 6...
- # $0
- # _____________/\______________
- # | $0[0] $0[1] $0[2] |
- # | __/\___ ____/\____ /\ |
- # | | | | | | | |
+ # $0
+ # ______________/\______________
+ # | $0[0] $0[1] $0[2] |
+ # | ___/\___ ____/\____ /\ |
+ # | | | | | | | |
m/ ( (<[A..E]>) (\d**{3..6}) (X?) ) /;
# Perl 6 simulating Perl 5...
- # $1
- # _______________/\________________
- # | $2 $3 $4 |
- # | __/\___ ____/\____ /\ |
- # | | | | | | | |
+ # $1
+ # ________________/\________________
+ # | $2 $3 $4 |
+ # | ___/\___ ____/\____ /\ |
+ # | | | | | | | |
m/ $1:=[ (<[A..E]>) (\d**{3..6}) (X?) ] /;
The non-capturing brackets don't introduce a scope, so the subpatterns within
@@ -2635,7 +2635,7 @@
In other words, aliasing and quantification are completely orthogonal.
For example:
- if m/ mv $0:=<file>+ / {
+ if ms/ mv $0:=<file>+ / {
# <file>+ returns a list of Match objects,
# so $0 contains an array of Match objects,
# one for each successful call to <file>
@@ -2644,7 +2644,7 @@
}
- if m/ mv $<from>:=(\S+ \s+)* / {
+ if m/ mv \s+ $<from>:=(\S+ \s+)* / {
# Quantified subpattern returns a list of Match objects,
# so $/<from> contains an array of Match
# objects, one for each successful match of the subpattern
@@ -2676,7 +2676,7 @@
An alias can also be specified using an array as the alias instead of a scalar.
For example:
- m/ mv @<from>:=[(\S+) \s+]* <dir> /;
+ m/ mv \s+ @<from>:=[(\S+) \s+]* <dir> /;
=item *
@@ -2714,18 +2714,18 @@
brackets, it captures the substrings matched by each repetition of the
brackets into separate elements of the corresponding array. That is:
- m/ mv $<files>:=[ f.. \s* ]* /; # $/<files> assigned a single
- # Match object containing the
- # complete substring matched by
- # the full set of repetitions
- # of the non-capturing brackets
-
- m/ mv @<files>:=[ f.. \s* ]* /; # $/<files> assigned an array,
- # each element of which is a
- # Match object containing
- # the substring matched by Nth
- # repetition of the non-
- # capturing bracket match
+ ms/ mv $<files>:=[ f.. \s* ]* /; # $/<files> assigned a single
+ # Match object containing the
+ # complete substring matched by
+ # the full set of repetitions
+ # of the non-capturing brackets
+
+ ms/ mv @<files>:=[ f.. \s* ]* /; # $/<files> assigned an array,
+ # each element of which is a
+ # Match object containing
+ # the substring matched by Nth
+ # repetition of the non-
+ # capturing bracket match
=item *
Modified: doc/trunk/design/syn/S06.pod
==============================================================================
--- doc/trunk/design/syn/S06.pod (original)
+++ doc/trunk/design/syn/S06.pod Wed Feb 28 07:55:51 2007
@@ -13,9 +13,9 @@
Maintainer: Larry Wall <[EMAIL PROTECTED]>
Date: 21 Mar 2003
- Last Modified: 22 Feb 2007
+ Last Modified: 28 Feb 2007
Number: 6
- Version: 72
+ Version: 73
This document summarizes Apocalypse 6, which covers subroutines and the
@@ -1609,21 +1609,12 @@
print $text while $count-- > 0;
}
-=item C<is context(I<TYPE>)>
+=item C<is context(I<ACCESS>)>
-Specifies the context that a parameter applies to its argument. Typically used
-to cause a final list parameter to apply a series of scalar contexts:
-
- # &format may have as many arguments as it likes,
- # each of which is evaluated in scalar context
-
- sub format([EMAIL PROTECTED] is context(Scalar)) {...}
-
-Note that the compiler may not be able to propagate such a scalar
-context to a function call used as an argument to a method or multisub
-whose signature is not visible until dispatch time. Such function
-call arguments are called in list context by default, and must be
-coerced to scalar context explicitly if that is desired.
+Specifies that the parameter is to be treated as an "environmental"
+variable, that is, a lexical that is accessible from the dynamic
+scope (see S02). If I<ACCESS> is omitted, defaults to readonly in
+any portions of the dynamic scope outside the current lexical scope.
=back