Revision 26167
- Date:
- 2009/04/10 00:44:36
- Files:
Legend:
- Added
- Removed
- Modified
-
docs/Perl6/Spec/S02-bits.pod
12 12 13 13 Maintainer: Larry Wall <larry@wall.org> 14 14 Date: 10 Aug 2004 15 Last Modified: 22 Mar 2009 15 Last Modified: 9 Apr 2009 16 16 Number: 2 17 Version: 161 17 Version: 162 18 18 19 19 This document summarizes Apocalypse 2, which covers small-scale 20 20 lexical items and typological issues. (These Synopses also contain … … 1783 1783 print $( foo() ) # foo called in item context 1784 1784 print @@( foo() ) # foo called in slice context 1785 1785 1786 The bare sigil is parsed as a list operator in rvalue context, so 1787 these mean the same thing: 1788 1789 print $ foo() # foo called in item context 1790 print @@ foo() # foo called in slice context 1791 1792 1786 In declarative contexts bare sigils may be used as placeholders for 1793 1787 anonymous variables: 1794 1788 … … 1799 1793 1800 1794 ($a, *, $c) = 1..3; 1801 1795 1796 Attempts to say something like: 1797 1798 ($a, $, $c) = 1..3; 1799 1800 will result in the message, "Anonymous variable requires declarator". 1801 1802 1802 1803 =item * 1803 1804 1804 1805 Ordinary package-qualified names look like in Perl 5: -
docs/Perl6/Spec/S03-operators.pod
12 12 13 13 Maintainer: Larry Wall <larry@wall.org> 14 14 Date: 8 Mar 2004 15 Last Modified: 18 Mar 2009 15 Last Modified: 9 Apr 2009 16 16 Number: 3 17 Version: 160 17 Version: 161 18 18 19 19 =head1 Overview 20 20 … … 1944 1944 @@ slice 1945 1945 % hash 1946 1946 1947 As listops, these look like terms from the left, but raise their 1948 precedence on the right sufficiently to govern list infix 1949 operators: 1947 These may only be used as functions with explicit parens: 1950 1948 1951 $ 1,2 Z 3,4 # [\(1,3),\(2,4)] 1952 @ 1,2 Z 3,4 # 1,3,2,4 1953 @@ 1,2 Z 3,4 # [1,3],[2,4] 1954 % 1,2 Z 3,4 # { 1 => 3, 2 => 4 } 1949 $(1,2 Z 3,4) # [\(1,3),\(2,4)] 1950 @(1,2 Z 3,4) # 1,3,2,4 1951 @@(1,2 Z 3,4) # [1,3],[2,4] 1952 %(1,2 Z 3,4) # { 1 => 3, 2 => 4 } 1955 1953 1956 $ 1,2 X 3,4 # [\(1,3),\(1,4),\(2,3),\(2,4)] 1957 @ 1,2 X 3,4 # 1,3,1,4,2,3,2,4 1958 @@ 1,2 X 3,4 # [1,3],[1,4],[2,3],[2,4] 1954 $(1,2 X 3,4) # [\(1,3),\(1,4),\(2,3),\(2,4)] 1955 @(1,2 X 3,4) # 1,3,1,4,2,3,2,4 1956 @@(1,2 X 3,4) # [1,3],[1,4],[2,3],[2,4] 1959 1957 1960 1958 These can also influence the result of functions that returns lists of captures: 1961 1959 1962 $ map { $_, $_*2 }, ^4 # [\(0,0),\(1,2),\(2,4),\(3,6)] 1963 @ map { $_, $_*2 }, ^4 # 0,0,1,2,2,4,3,6 1964 @@ map { $_, $_*2 }, ^4 # [0,0],[1,2],[2,4],[3,6] 1965 % map { $_, $_*2 }, ^4 # { 0 => 0, 1 => 2, 2 => 4, 3 => 6 } 1960 $(map { $_, $_*2 }, ^4) # [\(0,0),\(1,2),\(2,4),\(3,6)] 1961 @(map { $_, $_*2 }, ^4) # 0,0,1,2,2,4,3,6 1962 @@(map { $_, $_*2 }, ^4) # [0,0],[1,2],[2,4],[3,6] 1963 %(map { $_, $_*2 }, ^4) # { 0 => 0, 1 => 2, 2 => 4, 3 => 6 } 1966 1964 1965 The parens may not be omitted on the sigiled forms, but the alpha variants may 1966 be used as normal listops: 1967 1968 item map { $_, $_*2 }, ^4 # [\(0,0),\(1,2),\(2,4),\(3,6)] 1969 list map { $_, $_*2 }, ^4 # 0,0,1,2,2,4,3,6 1970 slice map { $_, $_*2 }, ^4 # [0,0],[1,2],[2,4],[3,6] 1971 hash map { $_, $_*2 }, ^4 # { 0 => 0, 1 => 2, 2 => 4, 3 => 6 } 1972 1967 1973 =item * 1968 1974 1969 1975 The C<item> contextualizer … … 2210 2216 2211 2217 Perl 5's C<${...}>, C<@{...}>, C<%{...}>, etc. dereferencing 2212 2218 forms are now C<$(...)>, C<@(...)>, C<%(...)>, etc. instead. 2213 Listop-like forms use the bare sigil following by whitespace. 2214 Use of the Perl 5 curly forms will result in an error message 2215 pointing the user to the new forms. 2219 (Use of the Perl 5 curly forms will result in an error message 2220 pointing the user to the new forms.) 2221 As in Perl 5, the parens may be dropped when dereferencing 2222 a scalar variable. 2216 2223 2217 2224 =item * 2218 2225 … … 2321 2328 to being a no-op in Perl 5). Along the same lines, C<?> imposes 2322 2329 a boolean (C<Bool>) context, and the C<|> unary operator imposes 2323 2330 a function-arguments (C<Capture>) context on its argument. 2324 Unary sigils impose the container context implied by their sigil. 2331 Unary sigils are allowed when followed by a C<$> sigil on a scalar variable; 2332 they impose the container context implied by their sigil. 2325 2333 As with Perl 5, however, C<$$foo[bar]> parses as C<( $($foo) )[bar]>, 2326 so you need C<$($foo[bar])> to mean the other way. 2334 so you need C<$($foo[bar])> to mean the other way. In other 2335 words, sigils are not really parsed as operators, and you must 2336 use the parenthetical form for anything complicated. 2327 2337 2328 2338 =item * 2329 2339 -
docs/Perl6/Spec/S06-routines.pod
13 13 14 14 Maintainer: Larry Wall <larry@wall.org> 15 15 Date: 21 Mar 2003 16 Last Modified: 19 Mar 2009 16 Last Modified: 9 Apr 2009 17 17 Number: 6 18 Version: 107 18 Version: 108 19 19 20 20 21 21 This document summarizes Apocalypse 6, which covers subroutines and the … … 1216 1216 1217 1217 Otherwise you'd have to say this: 1218 1218 1219 for @@tmp.zip.@@() -> [$i, $a] { say "$i: $a" } 1219 for @@tmp.zip.slice -> [$i, $a] { say "$i: $a" } 1220 1220 1221 1221 In list context the C<@@foo> notation is really a shorthand for C<[;](@@foo)>. 1222 1222 In particular, you can use C<@@foo> to interpolate a multidimensional slice … … 1232 1232 So 1233 1233 1234 1234 ('a'..*; 0..*) ==> *; 1235 for zip(@@() <== @foo) -> $a, $i, $x { ... } 1235 for zip(@@(*) <== @foo) -> $a, $i, $x { ... } 1236 1236 1237 1237 is the same as 1238 1238 1239 1239 'a'..* ==> *; 1240 1240 0..* ==> *; 1241 for zip(@@ <== @foo) -> $a, $i, $x { ... } 1241 for zip(@@(*) <== @foo) -> $a, $i, $x { ... } 1242 1242 1243 1243 which is the same as 1244 1244 … … 1254 1254 C<@()>, C<@@()> defaults to C<@@($/)>, and returns a multidimensional 1255 1255 view of any match that repeatedly applies itself with C<:g> and 1256 1256 the like. In contrast, C<@()> would flatten those into one list. 1257 It is an error to use C<@(*)> or C<@@(*)> in a context that doesn't 1258 supply a feed somehow. 1257 1259 1258 1260 =head2 Closure parameters 1259 1261