Author: larry
Date: Mon Oct  9 08:34:36 2006
New Revision: 12933

Modified:
   doc/trunk/design/syn/S02.pod
   doc/trunk/design/syn/S05.pod

Log:
Quote and regex adverbs may now take only parentheses as brackets.


Modified: doc/trunk/design/syn/S02.pod
==============================================================================
--- doc/trunk/design/syn/S02.pod        (original)
+++ doc/trunk/design/syn/S02.pod        Mon Oct  9 08:34:36 2006
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall <[EMAIL PROTECTED]>
   Date: 10 Aug 2004
-  Last Modified: 8 Oct 2006
+  Last Modified: 9 Oct 2006
   Number: 2
-  Version: 75
+  Version: 76
 
 This document summarizes Apocalypse 2, which covers small-scale
 lexical items and typological issues.  (These Synopses also contain
@@ -1476,17 +1476,17 @@
 There is now a generalized adverbial form of Pair notation.  The
 following table shows the correspondence to the "fatarrow" notation:
 
-    Fat arrow          Adverbial pair
-    =========          ==============
+    Fat arrow          Adverbial pair  Paren form
+    =========          ==============  ==========
     a => 1             :a
     a => 0             :!a
     a => 0             :a(0)
     a => $x            :a($x)
-    a => 'foo'         :a<foo>
-    a => <foo bar>     :a<foo bar>
-    a => «$foo @bar»   :a«$foo @bar»
-    a => {...}         :a{...}
-    a => [...]         :a[...]
+    a => 'foo'         :a<foo>         :a(<foo>)
+    a => <foo bar>     :a<foo bar>     :a(<foo bar>)
+    a => «$foo @bar»   :a«$foo @bar»   :a(«$foo @bar»)
+    a => {...}         :a{...}         :a({...})
+    a => [...]         :a[...]         :a([...])
     a => $a            :$a
     a => @a            :@a
     a => %a            :%a
@@ -1518,7 +1518,12 @@
 If that's not intended, you must use whitespace between the adverb and
 the opening bracket.  The syntax of individual adverbs is the same
 everywhere in Perl 6.  There are no exceptions based on whether an
-argument is wanted or not.  Except as noted above, the parser always
+argument is wanted or not.  (There is a minor exception for quote and
+regex adverbs, which accept I<only> parentheses as their bracketing
+operator, and ignore other brackets, which must be placed in parens
+if desired.  See "Paren form" in the table above.)
+
+Except as noted above, the parser always
 looks for the brackets.  Despite not indicating a true subscript,
 the brackets are similarly parsed as postfix operators.  As postfixes
 the brackets may be separated from their initial C<:foo> with either
@@ -1566,7 +1571,7 @@
 
     quote qx = 'qq:x';          # equivalent to P5's qx//
     quote qTO = 'qq:x:w:to';    # qq:x:w:to//
-    quote circumfix:<❰ ❱> = q:code { .quoteharder };  # or some such...
+    quote circumfix:<❰ ❱> = q:code{ .quoteharder };  # or some such...
 
 In particular, all these forms disable the lookahead for an adverbial argument,
 as if there were a space after the keyword.  So although
@@ -1594,10 +1599,8 @@
 
     q:n[stuff]
 
-is not so fine, if the user intended "stuff" to be the string rather
-than an argument to C<:n>.  Basically, you'll be fine if you just
-never use parens for quote delimiters, and always put a space after
-your adverbs.
+also happens to work because quote adverbs only all the paren form of
+bracketed adverbs.
 
 If this is all too much of a hardship, you can define your own quote
 adverbs and operators as standard macros.  The main difference is that,
@@ -1609,8 +1612,8 @@
 
     macro qn { 'q:n' }
 
-does I<not> disable the subsequent search for an argument to C<:n>.  To
-get the equivalent, you need to add a space:
+does I<not> disable the subsequent search for a parenthesized argument
+to C<:n>.  To get the equivalent, you need to add a space:
 
     macro qn { 'q:n ' }
 

Modified: doc/trunk/design/syn/S05.pod
==============================================================================
--- doc/trunk/design/syn/S05.pod        (original)
+++ doc/trunk/design/syn/S05.pod        Mon Oct  9 08:34:36 2006
@@ -14,9 +14,9 @@
    Maintainer: Patrick Michaud <[EMAIL PROTECTED]> and
                Larry Wall <[EMAIL PROTECTED]>
    Date: 24 Jun 2002
-   Last Modified: 8 Oct 2006
+   Last Modified: 9 Oct 2006
    Number: 5
-   Version: 36
+   Version: 37
 
 This document summarizes Apocalypse 5, which is about the new regex
 syntax.  We now try to call them I<regex> rather than "regular
@@ -108,8 +108,8 @@
 
 Every modifier must start with its own colon.  The delimiter must be
 separated from the final modifier by whitespace if it would otherwise be taken
-as an argument to the preceding modifier (which is true for any
-bracketing character).
+as an argument to the preceding modifier (which is true if and only if
+the next character is a left parenthesis.)
 
 =item *
 
@@ -180,7 +180,7 @@
 
 But in the case of
 
-     m:s {(a|\*) (b|\+)}
+     m:s{(a|\*) (b|\+)}
 
 or equivalently,
 
@@ -257,7 +257,7 @@
 which is almost the same as:
 
      $_.pos = 0;
-     s:c [ (<?ident>) = (\N+) $$] [$0 => $1] for 1..4;
+     s:c[ (<?ident>) = (\N+) $$] = "$0 => $1" for 1..4;
 
 except that the string is unchanged unless all four matches are found.
 However, ranges are allowed, so you can say C<:x(1..4)> to change anywhere
@@ -373,6 +373,13 @@
 
      m/:s alignment = [:i left|right|cent[er|re]] /
 
+As with modifiers outside, only parentheses are recognized as valid
+brackets for args to the adverb.  In particular:
+
+    m/:foo[xxx]/       Parses as :foo [xxx]
+    m/:foo{xxx}/       Parses as :foo {xxx}
+    m/:foo<xxx>/       Parses as :foo <xxx>
+
 =item *
 
 User-defined modifiers will be possible:
@@ -381,13 +388,13 @@
 
 =item *
 
-User-defined modifiers can also take arguments:
+User-defined modifiers can also take arguments, but only in parentheses:
 
          m:fuzzy('bare')/pattern/;
 
 =item *
 
-To use parens or brackets for your delimiters you have to separate:
+To use parens for your delimiters you have to separate:
 
          m:fuzzy (pattern);
 
@@ -2932,15 +2939,15 @@
 Any scalar assignment operator may be used; the substitution macro
 knows how to turn
 
-    $target ~~ s:g [pattern] op= expr
+    $target ~~ s:g[pattern] op= expr
 
 into something like:
 
-    $target.subst(rx:g [pattern], { $() op expr })
+    $target.subst(rx:g[pattern], { $() op expr })
 
 So, for example, you can multiply every dollar amount by 2 with:
 
-    s:g [\$ <( \d+ )>] *= 2
+    s:g[\$ <( \d+ )>] *= 2
 
 (Of course, the optimizer is free to do something faster than an actual
 method call.)

Reply via email to