Author: lwall Date: 2009-04-10 02:44:36 +0200 (Fri, 10 Apr 2009) New Revision: 26167
Modified: docs/Perl6/Spec/S02-bits.pod docs/Perl6/Spec/S03-operators.pod docs/Perl6/Spec/S06-routines.pod Log: Eliminate listop forms of sigils. Modified: docs/Perl6/Spec/S02-bits.pod =================================================================== --- docs/Perl6/Spec/S02-bits.pod 2009-04-09 23:27:43 UTC (rev 26166) +++ docs/Perl6/Spec/S02-bits.pod 2009-04-10 00:44:36 UTC (rev 26167) @@ -12,9 +12,9 @@ Maintainer: Larry Wall <la...@wall.org> Date: 10 Aug 2004 - Last Modified: 22 Mar 2009 + Last Modified: 9 Apr 2009 Number: 2 - Version: 161 + Version: 162 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -1783,12 +1783,6 @@ print $( foo() ) # foo called in item context print @@( foo() ) # foo called in slice context -The bare sigil is parsed as a list operator in rvalue context, so -these mean the same thing: - - print $ foo() # foo called in item context - print @@ foo() # foo called in slice context - In declarative contexts bare sigils may be used as placeholders for anonymous variables: @@ -1799,6 +1793,13 @@ ($a, *, $c) = 1..3; +Attempts to say something like: + + ($a, $, $c) = 1..3; + +will result in the message, "Anonymous variable requires declarator". + + =item * Ordinary package-qualified names look like in Perl 5: Modified: docs/Perl6/Spec/S03-operators.pod =================================================================== --- docs/Perl6/Spec/S03-operators.pod 2009-04-09 23:27:43 UTC (rev 26166) +++ docs/Perl6/Spec/S03-operators.pod 2009-04-10 00:44:36 UTC (rev 26167) @@ -12,9 +12,9 @@ Maintainer: Larry Wall <la...@wall.org> Date: 8 Mar 2004 - Last Modified: 18 Mar 2009 + Last Modified: 9 Apr 2009 Number: 3 - Version: 160 + Version: 161 =head1 Overview @@ -1944,26 +1944,32 @@ @@ slice % hash -As listops, these look like terms from the left, but raise their -precedence on the right sufficiently to govern list infix -operators: +These may only be used as functions with explicit parens: - $ 1,2 Z 3,4 # [\(1,3),\(2,4)] - @ 1,2 Z 3,4 # 1,3,2,4 - @@ 1,2 Z 3,4 # [1,3],[2,4] - % 1,2 Z 3,4 # { 1 => 3, 2 => 4 } + $(1,2 Z 3,4) # [\(1,3),\(2,4)] + @(1,2 Z 3,4) # 1,3,2,4 + @@(1,2 Z 3,4) # [1,3],[2,4] + %(1,2 Z 3,4) # { 1 => 3, 2 => 4 } - $ 1,2 X 3,4 # [\(1,3),\(1,4),\(2,3),\(2,4)] - @ 1,2 X 3,4 # 1,3,1,4,2,3,2,4 - @@ 1,2 X 3,4 # [1,3],[1,4],[2,3],[2,4] + $(1,2 X 3,4) # [\(1,3),\(1,4),\(2,3),\(2,4)] + @(1,2 X 3,4) # 1,3,1,4,2,3,2,4 + @@(1,2 X 3,4) # [1,3],[1,4],[2,3],[2,4] These can also influence the result of functions that returns lists of captures: - $ map { $_, $_*2 }, ^4 # [\(0,0),\(1,2),\(2,4),\(3,6)] - @ map { $_, $_*2 }, ^4 # 0,0,1,2,2,4,3,6 - @@ map { $_, $_*2 }, ^4 # [0,0],[1,2],[2,4],[3,6] - % map { $_, $_*2 }, ^4 # { 0 => 0, 1 => 2, 2 => 4, 3 => 6 } + $(map { $_, $_*2 }, ^4) # [\(0,0),\(1,2),\(2,4),\(3,6)] + @(map { $_, $_*2 }, ^4) # 0,0,1,2,2,4,3,6 + @@(map { $_, $_*2 }, ^4) # [0,0],[1,2],[2,4],[3,6] + %(map { $_, $_*2 }, ^4) # { 0 => 0, 1 => 2, 2 => 4, 3 => 6 } +The parens may not be omitted on the sigiled forms, but the alpha variants may +be used as normal listops: + + item map { $_, $_*2 }, ^4 # [\(0,0),\(1,2),\(2,4),\(3,6)] + list map { $_, $_*2 }, ^4 # 0,0,1,2,2,4,3,6 + slice map { $_, $_*2 }, ^4 # [0,0],[1,2],[2,4],[3,6] + hash map { $_, $_*2 }, ^4 # { 0 => 0, 1 => 2, 2 => 4, 3 => 6 } + =item * The C<item> contextualizer @@ -2210,9 +2216,10 @@ Perl 5's C<${...}>, C<@{...}>, C<%{...}>, etc. dereferencing forms are now C<$(...)>, C<@(...)>, C<%(...)>, etc. instead. -Listop-like forms use the bare sigil following by whitespace. -Use of the Perl 5 curly forms will result in an error message -pointing the user to the new forms. +(Use of the Perl 5 curly forms will result in an error message +pointing the user to the new forms.) +As in Perl 5, the parens may be dropped when dereferencing +a scalar variable. =item * @@ -2321,9 +2328,12 @@ to being a no-op in Perl 5). Along the same lines, C<?> imposes a boolean (C<Bool>) context, and the C<|> unary operator imposes a function-arguments (C<Capture>) context on its argument. -Unary sigils impose the container context implied by their sigil. +Unary sigils are allowed when followed by a C<$> sigil on a scalar variable; +they impose the container context implied by their sigil. As with Perl 5, however, C<$$foo[bar]> parses as C<( $($foo) )[bar]>, -so you need C<$($foo[bar])> to mean the other way. +so you need C<$($foo[bar])> to mean the other way. In other +words, sigils are not really parsed as operators, and you must +use the parenthetical form for anything complicated. =item * Modified: docs/Perl6/Spec/S06-routines.pod =================================================================== --- docs/Perl6/Spec/S06-routines.pod 2009-04-09 23:27:43 UTC (rev 26166) +++ docs/Perl6/Spec/S06-routines.pod 2009-04-10 00:44:36 UTC (rev 26167) @@ -13,9 +13,9 @@ Maintainer: Larry Wall <la...@wall.org> Date: 21 Mar 2003 - Last Modified: 19 Mar 2009 + Last Modified: 9 Apr 2009 Number: 6 - Version: 107 + Version: 108 This document summarizes Apocalypse 6, which covers subroutines and the @@ -1216,7 +1216,7 @@ Otherwise you'd have to say this: - for @@tmp.zip.@@() -> [$i, $a] { say "$i: $a" } + for @@tmp.zip.slice -> [$i, $a] { say "$i: $a" } In list context the C<@@foo> notation is really a shorthand for C<[;](@@foo)>. In particular, you can use C<@@foo> to interpolate a multidimensional slice @@ -1232,13 +1232,13 @@ So ('a'..*; 0..*) ==> *; - for zip(@@() <== @foo) -> $a, $i, $x { ... } + for zip(@@(*) <== @foo) -> $a, $i, $x { ... } is the same as 'a'..* ==> *; 0..* ==> *; - for zip(@@ <== @foo) -> $a, $i, $x { ... } + for zip(@@(*) <== @foo) -> $a, $i, $x { ... } which is the same as @@ -1254,6 +1254,8 @@ C<@()>, C<@@()> defaults to C<@@($/)>, and returns a multidimensional view of any match that repeatedly applies itself with C<:g> and the like. In contrast, C<@()> would flatten those into one list. +It is an error to use C<@(*)> or C<@@(*)> in a context that doesn't +supply a feed somehow. =head2 Closure parameters