[svn:perl6-synopsis] r9442 - doc/trunk/design/syn
Author: audreyt Date: Sat Jun 3 07:12:04 2006 New Revision: 9442 Modified: doc/trunk/design/syn/S05.pod Log: * At scw++'s request, add an explicit definition to the default : "\s+ if it's between two \w characters, \s* otherwise" Modified: doc/trunk/design/syn/S05.pod == --- doc/trunk/design/syn/S05.pod(original) +++ doc/trunk/design/syn/S05.podSat Jun 3 07:12:04 2006 @@ -14,9 +14,9 @@ Maintainer: Patrick Michaud <[EMAIL PROTECTED]> and Larry Wall <[EMAIL PROTECTED]> Date: 24 Jun 2002 - Last Modified: 13 May 2006 + Last Modified: 3 June 2006 Number: 5 - Version: 24 + Version: 25 This document summarizes Apocalypse 5, which is about the new regex syntax. We now try to call them I because they haven't been @@ -631,8 +631,10 @@ / /# was /(?=pattern)/ / / # was /(? /# match whitespace by :s policy / /# match the SPACE character (U+0020) + / /# match "whitespace": + # \s+ if it's between two \w characters, + # \s* otherwise / / # match only at a particular StrPos # short for
[svn:perl6-synopsis] r9435 - doc/trunk/design/syn
Author: audreyt Date: Sat Jun 3 05:49:52 2006 New Revision: 9435 Modified: doc/trunk/design/syn/S04.pod Log: * S04 - Change this example: if -e { say "exists" } { extra() } to this: if rand { say "exists" } { extra() } Because bare "-e" may be removed along with all $_-defaulting forms (to be replaced by .-e), but bare "rand" defaults to 1, and as such should probably be still there. Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podSat Jun 3 05:49:52 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 19 Aug 2004 - Last Modified: 5 May 2006 + Last Modified: 3 June 2006 Number: 4 - Version: 20 + Version: 21 This document summarizes Apocalypse 4, which covers the block and statement syntax of Perl. @@ -638,18 +638,18 @@ in front of it will be taken as terminating the conditional, even if the conditional expression could take another argument. Therefore -if -e { say "exists" } { extra() } -if -e -> $x { say "exists" } { extra() } +if rand { say "exists" } { extra() } +if rand -> $x { say "exists" } { extra() } is always parsed as -if (-e) { say "exists" }; { extra() } -if (-e) -> $x { say "exists" }; { extra() } +if (rand) { say "exists" }; { extra() } +if (rand) -> $x { say "exists" }; { extra() } rather than -if (-e { say "exists" }) { extra() } -if (-e (-> $x { say "exists" })) { extra() } +if (rand { say "exists" }) { extra() } +if (rand (-> $x { say "exists" })) { extra() } Apart from that, it is illegal to use a bare closure where an operator is expected. (Remove the whitespace if you wish it to be
[svn:perl6-synopsis] r9527 - doc/trunk/design/syn
Author: audreyt Date: Wed Jun 7 08:30:53 2006 New Revision: 9527 Modified: doc/trunk/design/syn/S06.pod Log: * S06: Fixed a minor typo noticed by szbalint++. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podWed Jun 7 08:30:53 2006 @@ -2107,9 +2107,9 @@ as the original subroutine, but has the values passed to C<.assuming> already bound to the corresponding parameters: -$all = $textfrom(0); # same as: $all = substr($text,0,Inf); -$some = $textfrom(50); # same as: $some = substr($text,50,Inf); -$last = $textfrom(-1); # same as: $last = substr($text,-1,Inf); +$all = textfrom(0); # same as: $all = substr($text,0,Inf); +$some = textfrom(50); # same as: $some = substr($text,50,Inf); +$last = textfrom(-1); # same as: $last = substr($text,-1,Inf); The result of a C statement is a (compile-time) object that also has an C<.assuming> method, allowing the user to bind parameters in all the
[svn:perl6-synopsis] r9535 - doc/trunk/design/syn
Author: audreyt Date: Sat Jun 10 19:51:22 2006 New Revision: 9535 Modified: doc/trunk/design/syn/S03.pod Log: * S03: the SIMPLE forms can use a more robust recursive definition. also, include $$a and $::('$a') as obviously simple as well. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podSat Jun 10 19:51:22 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 8 Mar 2004 - Last Modified: 4 Jun 2006 + Last Modified: 11 Jun 2006 Number: 3 - Version: 37 + Version: 38 =head1 Changes to existing operators @@ -114,15 +114,18 @@ still works fine. The distinction between scalar and list assignment is similar to the way Perl 5 does it, but has to be a little different because we can no longer decide on the basis of -the sigil. The following forms are defined as "obviously simple", +the sigil. The following forms are defined as "simple lvalues", and imply scalar assignment: $a # simple scalar variable +$(ANY) # scalar dereference (including $$a) +$::(ANY)# symbolic scalar dereference ANY[SIMPLE]# single simple subscript ANY{SIMPLE}# single simple subscript ANY # single literal subscript -Where SIMPLE is defined as +Where SIMPLE is (recursively) defined as one of the forms above, +plus the following forms: 123# single literal 'x'# single literal @@ -133,8 +136,6 @@ ~TERM # any single term coerced to string ?TERM # any single term coerced to boolean !TERM # any single term coerced to boolean -ANY[SIMPLE]# any of these simples used as subscript recursively -ANY{SIMPLE}# any of these simples used as subscript recursively We also include:
[svn:perl6-synopsis] r9536 - doc/trunk/design/syn
Author: audreyt Date: Sat Jun 10 20:02:44 2006 New Revision: 9536 Modified: doc/trunk/design/syn/S03.pod Log: * S03: allow post-assignment forms to be SIMPLE: $x[$y + $z] # simple scalar $x[$y += $z]# simple scalar, too Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podSat Jun 10 20:02:44 2006 @@ -147,8 +147,9 @@ precedence levels autoincrement, exponentiation, symbolic unary, multiplicative, and additive; but these are limited to standard operators that are known to return numbers, strings, or booleans. -(Operators that imply list operations are excluded: C<$>, C<@>, -and C, for instance. Hyper operators are also excluded.) +(Operators that imply list operations are excluded: C<@>, C<%>, +and C, for instance. Hyper operators are also excluded, but +post-assigment forms such as C is allowed.) All other forms imply list assignment, and will evaluate both sides of the assignment in list context (eventually). However, this is
[svn:perl6-synopsis] r9537 - doc/trunk/design/syn
Author: audreyt Date: Sat Jun 10 20:23:30 2006 New Revision: 9537 Modified: doc/trunk/design/syn/S03.pod Log: * S03: the ()= form is no more; reflect it in the operator table. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podSat Jun 10 20:23:30 2006 @@ -996,9 +996,9 @@ tight and && tight or|| ^^ // ternary ?? !! -assignment = := ::= += -= **= xx= .= etc. (and also =>) +assignment => := ::= += -= **= xx= .= etc. (also = with simple lvalues) loose unary true not -list ops, print push any all etc. and ()= rightward +list ops, print push any all etc. (also = with non-simple lvalues) list infix ¥ <== ==> loose and and loose oror xor err
[svn:perl6-synopsis] r9538 - doc/trunk/design/syn
Author: audreyt Date: Sat Jun 10 21:55:09 2006 New Revision: 9538 Modified: doc/trunk/design/syn/S02.pod Log: * S02: Subscripts are now always in list context, period. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podSat Jun 10 21:55:09 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 10 Aug 2004 - Last Modified: 23 May 2006 + Last Modified: 11 Jun 2006 Number: 2 - Version: 43 + Version: 44 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -629,21 +629,22 @@ =item * The context in which a subscript is evaluated is no longer controlled -by the sigil either. Subscripts are always evaluated in scalar context -when used as a lvalue, and list context when used as a rvalue. +by the sigil either. Subscripts are always evaluated in list context. If you need to force inner context to scalar, we now have convenient single-character context specifiers such as + for numbers and ~ for strings. Conversely, put parenthesis around the lvalue expression to force inner context to list: -@x[f()] = g(); # scalar context for f() and g() -@x[f()] = @y[g()]; # scalar context for f(), list context for g() -@x[f()] = @y[+g()]; # scalar context for f() and g() - -(@x[f()]) = g(); # list context for f() and g() -(@x[f()]) = @y[g()]; # list context for f() and g() -(@x[f()]) = @y[+g()]; # list context for f(), scalar 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() and g() +# -- see S03 for "SIMPLE" lvalues + +@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() =item *
[svn:perl6-synopsis] r9575 - doc/trunk/design/syn
Author: audreyt Date: Sun Jun 11 17:16:35 2006 New Revision: 9575 Modified: doc/trunk/design/syn/S03.pod Log: * S03: typo, nit, etc, reported by masak++. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podSun Jun 11 17:16:35 2006 @@ -149,10 +149,10 @@ operators that are known to return numbers, strings, or booleans. (Operators that imply list operations are excluded: C<@>, C<%>, and C, for instance. Hyper operators are also excluded, but -post-assigment forms such as C is allowed.) +post-assigment forms such as C are allowed. All other forms imply list assignment, and will evaluate both sides -of the assignment in list context (eventually). However, this is +of the assignment in list context at runtime. However, this is primarily a syntactic distinction, and no semantic or type information is used, since it influences subsequent parsing. In particular, even if a function is known to return a scalar value from its declaration,
[svn:perl6-synopsis] r9589 - doc/trunk/design/syn
Author: audreyt Date: Mon Jun 12 00:42:35 2006 New Revision: 9589 Modified: doc/trunk/design/syn/S02.pod Log: * S02: more elimination of lvalue-parenthesis form, spotted by spinclad++ Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podMon Jun 12 00:42:35 2006 @@ -632,9 +632,7 @@ by the sigil either. Subscripts are always evaluated in list context. If you need to force inner context to scalar, we now have convenient -single-character context specifiers such as + for numbers and ~ for strings. -Conversely, put parenthesis around the lvalue expression to force inner -context to list: +single-character context specifiers such as + for numbers and ~ for strings: @x[f()] = g(); # list context for f() and g() @x[f()] = +g(); # list context for f(), scalar context for g()
[svn:perl6-synopsis] r9625 - doc/trunk/design/syn
Author: audreyt Date: Mon Jun 12 18:32:09 2006 New Revision: 9625 Modified: doc/trunk/design/syn/S03.pod Log: * S03: Even more typo/nit cleanup; also clarify that while prefix:<%> is not "simple" scalar lvalue, infix:<%> is. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podMon Jun 12 18:32:09 2006 @@ -147,9 +147,11 @@ precedence levels autoincrement, exponentiation, symbolic unary, multiplicative, and additive; but these are limited to standard operators that are known to return numbers, strings, or booleans. -(Operators that imply list operations are excluded: C<@>, C<%>, -and C, for instance. Hyper operators are also excluded, but -post-assigment forms such as C are allowed. + +Operators that imply list operations are excluded: prefix C<@>, +prefix C<%> and infix C, for instance. Hyper operators are +also excluded, but post-assigment forms such as C +are allowed. All other forms imply list assignment, and will evaluate both sides of the assignment in list context at runtime. However, this is
[svn:perl6-synopsis] r9667 - doc/trunk/design/syn
Author: audreyt Date: Fri Jun 16 01:27:30 2006 New Revision: 9667 Modified: doc/trunk/design/syn/S02.pod Log: * S02: &?SUB is no more - it's now &?ROUTINE since it also works in method. Also $?SUBNAME is now &?ROUTINE.name. (It's already that way in S06, this just syncs with S06.) Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podFri Jun 16 01:27:30 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 10 Aug 2004 - Last Modified: 11 Jun 2006 + Last Modified: 16 Jun 2006 Number: 2 - Version: 44 + Version: 45 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -1074,10 +1074,8 @@ $?GRAMMAR Which grammar am I in? @?GRAMMAR Which grammars am I in? $?PARSERWhich Perl grammar was used to parse this statement? -&?SUB Which sub am I in? -@?SUB Which subs am I in? -$?SUBNAME Which sub name am I in? -@?SUBNAME Which sub names am I in? +&?ROUTINE Which routine am I in? +@?ROUTINE Which routines am I in? &?BLOCK Which block am I in? @?BLOCK Which blocks am I in? $?LABEL Which block label am I in? @@ -1804,9 +1802,9 @@ yourself. Each chunk has a C<.linenum> property that indicates its starting line within the source file. -There is also a new C<$?SUBNAME> variable containing the name of current -lexical sub. The lexical sub itself is C<&?SUB>. The current block -is C<&?BLOCK>. If the block has a label, that shows up in C<$?BLOCKLABEL>. +The lexical routine itself is C<&?ROUTINE>; you can get its name with +C<&ROUTINE.name>. The current block is C<&?BLOCK>. If the block has a label, +that shows up in C<&?BLOCK.label>. =item *
[svn:perl6-synopsis] r9717 - doc/trunk/design/syn
Author: audreyt Date: Fri Jun 23 07:55:16 2006 New Revision: 9717 Modified: doc/trunk/design/syn/S06.pod Log: * S06: Correct an extra comma in the comment: for @foo, sub { ... } should be written as for @foo sub { ... } if the sub is to be taken as the loop body. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podFri Jun 23 07:55:16 2006 @@ -142,7 +142,7 @@ $sq = -> $val { $val**2 }; # Same as: $sq = sub ($val) { $val**2 }; -for @list -> $elem {# Same as: for @list, sub ($elem) { +for @list -> $elem {# Same as: for @list sub ($elem) { print "$elem\n";# print "$elem\n"; } # }
[svn:perl6-synopsis] r9718 - doc/trunk/design/syn
Author: audreyt Date: Mon Jun 26 14:27:49 2006 New Revision: 9718 Modified: doc/trunk/design/syn/S06.pod Log: * S06: This is invalid syntax: for @list sub { ... } because statement control only admins pointy or bare blocks. Since pointies and anonymous subs are actually very dissimilar (for "return" handling etc), we don't show the translation anymore Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podMon Jun 26 14:27:49 2006 @@ -140,11 +140,13 @@ given traits. Syntactically a pointy sub is parsed exactly like a bare block. -$sq = -> $val { $val**2 }; # Same as: $sq = sub ($val) { $val**2 }; +my $sq = -> $val { $val**2 }; +say $sq(10); # 100 -for @list -> $elem {# Same as: for @list sub ($elem) { -print "$elem\n";# print "$elem\n"; -} # } +my @list = 1..3; +for @list -> $elem { +say $elem; # prints "1\n2\n3\n" +} It also behaves like a block with respect to control exceptions. If you C from within a pointy sub, it will return from the innermost
[svn:perl6-synopsis] r9719 - doc/trunk/design/syn
Author: audreyt Date: Wed Jun 28 18:37:41 2006 New Revision: 9719 Modified: doc/trunk/design/syn/S06.pod Log: * S06: anonymous methods is part of Perl 6, so we use that instead of the Perl5esque "sub" for FETCH and STORE. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podWed Jun 28 18:37:41 2006 @@ -226,10 +226,10 @@ sub checklastval ($passwd) is rw { return new Proxy: -FETCH => sub ($self) { +FETCH => method { return lastval(); }, -STORE => sub ($self, $val) { +STORE => method ($val) { die unless check($passwd); lastval() = $val; };
[svn:perl6-synopsis] r9720 - doc/trunk/design/syn
Author: audreyt Date: Wed Jun 28 18:43:52 2006 New Revision: 9720 Modified: doc/trunk/design/syn/S06.pod Log: * S06: Macros now re-splice in runtime when called as functions; this closes the unspecced "taking ¯o as an object and call it" loophole in S06. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podWed Jun 28 18:43:52 2006 @@ -2158,6 +2158,15 @@ original language and know which parts of the derived program come from which parts of the user's view of the program. +If you call a macro at runtime, the result of the macro is automatically +evaluated again, so the two calls below prints the same thing: + +macro f { '1 + 1' } +say f();# compile-time call to &f +say &f(); # runtime call to &f + +=head2 Quasiquoting + In aid of returning syntax tree, Perl provides a "quasiquoting" mechanism using the quote C, followed by a block intended to represent an AST:
[svn:perl6-synopsis] r9721 - doc/trunk/design/syn
Author: audreyt Date: Wed Jun 28 18:49:13 2006 New Revision: 9721 Modified: doc/trunk/design/syn/S06.pod doc/trunk/design/syn/S10.pod doc/trunk/design/syn/S12.pod Log: * Separate multi/single dispatch and method/sub completely in the nomenclature; the "invocant" is always the object for a method call now, and becomes totally orthogonal with the concepts of multi and "long names". * To reflect this change, multiple long names are now separated semicolons, and the invocant are separated with a colon, so this particular ambiguity was resolved: multi method foo ($x: $y) # is $x invocant or long name? Now it's unambiguously one of the two: multi method foo ($x: $y) # $x is invocant multi method foo ($x; $y) # $x is long name Thanks to TimToady++ and dconway++ for working out this issue; blame me for errors in ghost-writing. :-) Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podWed Jun 28 18:49:13 2006 @@ -471,7 +471,7 @@ list, with a colon (rather than a comma) immediately after it: method get_name ($self:) {...} -method set_name ($me: $newname) {...} +method set_name ($_: $newname) {...} The corresponding argument (the invocant) is evaluated in scalar context and is passed as the left operand of the method call operator: Modified: doc/trunk/design/syn/S10.pod == --- doc/trunk/design/syn/S10.pod(original) +++ doc/trunk/design/syn/S10.podWed Jun 28 18:49:13 2006 @@ -88,7 +88,7 @@ that distinguish declaration from definition, but are not restricted to declaring subs. A run-time declarator multisub is declared as: -multi CANDO ( MyPackage, $type, $name: *%args --> Container) +multi CANDO ( MyPackage, $type, $name; *%args --> Container) which stands in for the declaration of a container object within another container object; it is called when anyone is searching for @@ -100,10 +100,10 @@ name requested. In any case, there may be multiple C routines that are dispatched via MMD: -multi CANDO ( MyPackage, Item, $name: *%args --> Container) -multi CANDO ( MyPackage, Array, $name: *%args --> Container) -multi CANDO ( MyPackage, Hash, $name: *%args --> Container) -multi CANDO ( MyPackage, Code, $name: *%args --> Container) +multi CANDO ( MyPackage, Item, $name; *%args --> Container) +multi CANDO ( MyPackage, Array, $name; *%args --> Container) +multi CANDO ( MyPackage, Hash, $name; *%args --> Container) +multi CANDO ( MyPackage, Code, $name; *%args --> Container) The package itself is just passed as the first argument, since it's the container object. Subsequent arguments @@ -129,9 +129,9 @@ When the package in question is a class, it is also possible to declare real methods or submethods: -multi method CANDO ($self: Code, $name: *%args --> Container) +multi method CANDO ($self: Code, $name; *%args --> Container) -multi submethod CANDO ($self: Item, $name: *%args --> Container) +multi submethod CANDO ($self: Item, $name; *%args --> Container) The method form is inherited by subclasses. Submethods are never inherited but may still do MMD within the class. (Ordinary multisubs Modified: doc/trunk/design/syn/S12.pod == --- doc/trunk/design/syn/S12.pod(original) +++ doc/trunk/design/syn/S12.podWed Jun 28 18:49:13 2006 @@ -153,7 +153,7 @@ =head1 Methods -Methods are subroutines declared in a class with the C keyword: +Methods are routines declared in a class with the C keyword: method doit ($a, $b, $c) { ... } method doit ($self: $a, $b, $c) { ... } @@ -170,6 +170,14 @@ that will be optimized away. (The current lexically-determined class may always be named as C<::?CLASS> even in anonymous classes or roles.) +To mark an explicit invocant, just put a colon after it: + +method doit ($x: $a, $b, $c) { ... } + +This is true also for multi methods: + +multi method doit ($x: $a; $b; $c) { ... } + Private methods are declared using C: my method think (Brain $self: $thought) @@ -533,7 +541,7 @@ For any method name, there may be some number of candidate methods that could handle the request: typically, inherited methods or -multimethod variants. The ordinary "dot" operator dispatches +multi variants. The ordinary "dot" operator dispatches to a method in the standard fashion. There are also "dot" variants that call some number of methods with the same name: @@ -555,7 +563,7 @@ :ascendant # most-derived first, like destruction order :descendant # least-derived first,
[svn:perl6-synopsis] r9724 - doc/trunk/design/syn
Author: audreyt Date: Thu Jun 29 19:34:45 2006 New Revision: 9724 Modified: doc/trunk/design/syn/S02.pod Log: * S02: kolibrie++ noticed that a heredoc without a semicolon is confusing, so we reasserted the Perl5 semantics by a TimToady++ ruling. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podThu Jun 29 19:34:45 2006 @@ -1811,15 +1811,18 @@ Heredocs are no longer written with C<<< << >>>, but with an adverb on any other quote construct: -print qq:to/END/ +print qq:to/END/; Give $amount to the man behind curtain number $curtain. END -Other adverbs are also allowed: +Other adverbs are also allowed, as are multiple heredocs within the same +expression: -print q:c:to/END/ +print q:c:to/END/, q:to/END/; Give $100 to the man behind curtain number {$curtain}. END +Here is a $non-interpolated string +END =item *
[svn:perl6-synopsis] r9812 - doc/trunk/design/syn
Author: audreyt Date: Tue Jul 4 15:37:53 2006 New Revision: 9812 Modified: doc/trunk/design/syn/S11.pod Log: * S11: To maintain implementation neutrality, the p6-in-p5 incantation is no longer: use v6-pugs; it's now: use v6-**; Modified: doc/trunk/design/syn/S11.pod == --- doc/trunk/design/syn/S11.pod(original) +++ doc/trunk/design/syn/S11.podTue Jul 4 15:37:53 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 27 Oct 2004 - Last Modified: 22 Apr 2006 + Last Modified: 4 Jul 2006 Number: 11 - Version: 12 + Version: 13 =head1 Overview @@ -272,10 +272,10 @@ means the same thing. As a variant of that, the current Perl 5 incantation to switch to Perl 6 parsing is -use v6-pugs; +use v6-**; (though in Perl 5 this actually ends up calling the v6.pm module with a -'-pugs' argument for insane-but-useful reasons.) +C<-**> argument for insane-but-useful reasons.) For wildcards any valid smartmatch selector works:
[svn:perl6-synopsis] r9815 - doc/trunk/design/syn
Author: audreyt Date: Wed Jul 5 22:28:06 2006 New Revision: 9815 Modified: doc/trunk/design/syn/S11.pod Log: * S11: TimToady++ changes this: use v6-**; # this caused warnings in perl5 to this: use v6-alpha; which has the good effect of denoting this is _not_ Perl 6.0.0 and the syntax is subject to change. Modified: doc/trunk/design/syn/S11.pod == --- doc/trunk/design/syn/S11.pod(original) +++ doc/trunk/design/syn/S11.podWed Jul 5 22:28:06 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 27 Oct 2004 - Last Modified: 4 Jul 2006 + Last Modified: 6 Jul 2006 Number: 11 - Version: 13 + Version: 14 =head1 Overview @@ -265,17 +265,19 @@ to guarantee that you get the unembraced Perl. C<:-)> -Perl is the default module name, so +Perl is the default module name, so this means the same thing: use v6-cpan:TPF; -means the same thing. As a variant of that, the current Perl 5 -incantation to switch to Perl 6 parsing is - -use v6-**; - -(though in Perl 5 this actually ends up calling the v6.pm module with a -C<-**> argument for insane-but-useful reasons.) +Before the full specification of Perl 6.0.0 is released, you can use C +as the author slot to denote a program using syntax that is still subject +to change: + +use v6-alpha; + +The C line also serves as the Perl 5 incantation to switch to +Perl 6 parsing. In Perl 5 this actually ends up calling the v6.pm module with a +C<-alpha> argument, for insane-but-useful reasons. For wildcards any valid smartmatch selector works:
[svn:perl6-synopsis] r10308 - doc/trunk/design/syn
Author: audreyt Date: Wed Jul 19 13:12:50 2006 New Revision: 10308 Modified: doc/trunk/design/syn/S02.pod Log: * S02 proof-editing with Uri Guttman: Batch #1. These edits introduce no semantic changes to the spec; it's all strictly English cleanups. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podWed Jul 19 13:12:50 2006 @@ -14,7 +14,7 @@ Date: 10 Aug 2004 Last Modified: 19 July 2006 Number: 2 - Version: 53 + Version: 54 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -57,8 +57,8 @@ since they're bidirectional but not in the Ps/Pe set. Characters with no corresponding closing character do not qualify -as opening brackets. This includes the second section of the BidiMirroring -data table, as well as C and C. +as opening brackets. This includes the second section of the Unicode +BidiMirroring data table, as well as C and C. If a character is already used in Ps/Pe mappings, then its entry in BidiMirroring is ignored. Therefore C maps to C, @@ -86,10 +86,10 @@ Multiline comments are provided by extending the syntax of POD to nest C<=begin comment>/C<=end comment> correctly without the need -for C<=cut>. (Doesn't have to be "comment"--any unrecognized POD -stream will do to make it a comment. Bare C<=begin> and C<=end> -probably aren't good enough though, unless you want all your comments -to end up in the manpage...) +for C<=cut>. The format name does not have to be C -- any +unrecognized format name will do to make it a comment. (However, +bare C<=begin> and C<=end> probably aren't good enough, because all +comments in them will show up in the formatted output.) We have single paragraph comments with C<=for comment> as well. That lets C<=for> keep its meaning as the equivalent of a C<=begin> @@ -102,7 +102,8 @@ =item * Embedded comments are supported as a variant on quoting syntax, introduced -by C<#> plus any user-selected bracket characters (see definition above): +by C<#> plus any user-selected bracket characters (as defined in +L above): say #( embedded comment ) "hello, world!"; @@ -112,25 +113,29 @@ embedded comments 」.say; -There must be no space between the # and the opening bracket character. -(There may be the I of space for some double-wide -characters, however, such as the corner quotes above.) Brackets may -be nested following the same policy as ordinary quote brackets. +Brackets may be nested, following the same policy as ordinary quote brackets. + +There must be no space between the C<#> and the opening bracket character. +(There may be the I of space for some double-wide +characters, however, such as the corner quotes above.) + +=item * As a special case to facilitate commenting out sections of code with -C, C<#> on the left margin is always considered a line-end -comment rather than an embedded comment, even if followed by a -bracketing character. +C, C<#> on the beginning of line is always considered a line-end +comment rather than an embedded comment, even if followed by a bracketing +character. =item * -For all quoting constructs that use user-selected brackets, multiple, -adjacent, identical opening brackets must always be matched by an -equal number of adjacent closing brackets. Bracket counting naturally -applies only to sets of brackets of the same length: +For all quoting constructs that use user-selected brackets, you can open +with multiple identical bracket characters, which must by closed by the +same number of closing brackets. Counting of nested brackets applies only +to pairs of brackets of the same length as the opening brackets: say #{{ - Comment contains unmatched } and { { { { plus a counted {{ ... }} pair. +This comment contains unmatched } and { { { { (ignored) +Plus a nested {{ ... }} pair(counted) }} q<< <> >> # says "<>" Note however that bare circumfix or postcircumfix C<<< <<...>> >>> is @@ -187,8 +192,8 @@ In general, whitespace is optional in Perl 6 except where it is needed to separate constructs that would be misconstrued as a single token or other syntactic unit. (In other words, Perl 6 follows the standard -"longest-token" principle, or in the cases of large constructs, a -"prefer shifting to reducing" principle. See Grammatical Categories +I principle, or in the cases of large constructs, a +I principle. See L below for more on how a Perl program is analyzed into tokens.) This is an unchanging deep rule, but the surface ramifications of
[svn:perl6-synopsis] r10312 - doc/trunk/design/syn
Author: audreyt Date: Wed Jul 19 15:10:38 2006 New Revision: 10312 Modified: doc/trunk/design/syn/S02.pod Log: * S02 proof-editing with Uri Guttman: Batch #2. * One semantic change to address an unspecified point: plural magicals like @?BLOCK etc are ordered from innermost to outermost (i.e. in the same order as lookups.) Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podWed Jul 19 15:10:38 2006 @@ -14,7 +14,7 @@ Date: 10 Aug 2004 Last Modified: 19 July 2006 Number: 2 - Version: 54 + Version: 55 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -461,9 +461,10 @@ respectively, and do not promote to arbitrary precision, though larger representations are always allowed for temporary values. Unless qualified with a number of bits, C and C types default -to the largest native types that run at full speed. Untyped numeric -scalars use C and C semantics rather than C and C. +to the largest native types that run at full speed. +Numeric values in untyped variables use C and C semantics +rather than C and C. =item * @@ -586,7 +587,7 @@ =item * -The C<$pkg'var> syntax is dead. Use C<$pkg::var> instead. +The C<$Package'var> syntax is gone. Use C<$Package::var> instead. =item * @@ -601,15 +602,19 @@ @@ multislice view of @ Within a declaration, the C<&> sigil also declares the visibility of the -subroutine name without the sigil within the scope of the declaration. +subroutine name without the sigil within the scope of the declaration: + +my &func := sub { say "Hi" }; +func; # calls &func Within a signature or other declaration, the C<::> sigil followed by an -identifier marks a parametric type that also declares the visibility +identifier marks a type variable that also declares the visibility of a package/type name without the sigil within the scope of the declaration. The first such declaration within a scope is assumed to be an unbound type, and takes the actual type of its associated argument. With subsequent declarations in the same scope the use of the sigil is optional, since the bare type name is also declared. + A declaration nested within must not use the sigil if it wishes to refer to the same type, since the inner declaration would rebind the type. (Note that the signature of a pointy block counts as part @@ -658,15 +663,17 @@ =item * -To get a Perlish representation of any data value, use the C<.perl> -method. This will put quotes around strings, square brackets around -list values, curlies around hash values, constructors around objects, -etc., such that standard Perl could reparse the result. +To get a Perlish representation of any object, use the C<.perl> method. +Like the C module in Perl 5, the C<.perl> method will put +quotes around strings, square brackets around list values, curlies around +hash values, constructors around objects, etc., so that Perl can evaluate +the result back to the same object. =item * -To get a formatted representation of any scalar data value, use -the C<.fmt('%03d')> method to do an implicit sprintf on the value. +To get a formatted representation of any scalar value, use the +C<.fmt('%03d')> method to do an implicit C on the value. + To format an array value separated by commas, supply a second argument: C<.fmt('%03d', ', ')>. To format a hash value or list of pairs, include formats for both key and value in the first string: C<< .fmt('%s: %s', "\n") >>. @@ -710,16 +717,16 @@ 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 -for more about parameter binding. +for more about binding. =item * -An argument list object (C) may be created with backslashed parens: +An argument list may be captured into an object with backslashed parens: $args = \(1,2,3,:mice) -Values in C are parsed as ordinary expressions, marked as invocant, -positional, named, and so on. +Values in a C object are parsed as ordinary expressions, marked as +invocant, positional, named, and so on. Like C objects, C objects are immutable in the abstract, but evaluate their arguments lazily. Before everything inside a C is @@ -757,22 +764,20 @@ =item * -A signature object (C) may be created with coloned parens: +A signature object (C) may be created with colon-prefixed parens: -my ::MySig = :(Int,Num,Complex, Status :mice) +my ::MySig ::= :(Int, Num, Complex, Status :mice) -A signature's values are parsed a
[svn:perl6-synopsis] r10314 - doc/trunk/design/syn
Author: audreyt Date: Wed Jul 19 20:02:34 2006 New Revision: 10314 Modified: doc/trunk/design/syn/S02.pod Log: * S02: Typo fixes from Agent Zhang and TimToady++. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podWed Jul 19 20:02:34 2006 @@ -399,7 +399,7 @@ respectively on the array. The same methods apply to strings as well. There is no C<.length> method for either arrays or strings, because C -does not specify an unit. +does not specify a unit. =item * @@ -743,8 +743,8 @@ $args = \3; # same as "$args = \(3)" $$args; # same as "$args as Scalar" or "Scalar($args)" -@$args; # same as '$args as Array" or "Array($args)" -%$args; # same as '$args as Hash" or "Hash($args)" +@$args; # same as "$args as Array" or "Array($args)" +%$args; # same as "$args as Hash" or "Hash($args)" When cast into an array, you can access all the positional arguments; into a hash, all named arguments; into a scalar, its invocant. @@ -789,7 +789,8 @@ Whitespace is not allowed before the parens, but there is a corresponding C<.()> operator, plus the "long dot" forms that allow -you to insert optional whitespace and comments between dots: +you to insert optional whitespace and comments between the backslash +and the dot: &foo\ .($arg1, $arg2); &foo\#[ @@ -1064,7 +1065,7 @@ not see any lexical variables or their values, unless you copy those values into C<%*ENV> to change what subprocesses see: -temp %*ENV{LANG} = $+LANG; # may be modifed by parent +temp %*ENV{LANG} = $+LANG; # may be modified by parent system "greet"; =item *
[svn:perl6-synopsis] r10348 - doc/trunk/design/syn
Author: audreyt Date: Fri Jul 21 11:40:37 2006 New Revision: 10348 Modified: doc/trunk/design/syn/S02.pod Log: * S02: rodi++ pointed out a nit: "say q<< <> >>" should print " <> " not "<>". Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podFri Jul 21 11:40:37 2006 @@ -136,7 +136,7 @@ say #{{ This comment contains unmatched } and { { { { (ignored) Plus a nested {{ ... }} pair(counted) -}} q<< <> >> # says "<>" +}} q<< <> >> # says " <> " Note however that bare circumfix or postcircumfix C<<< <<...>> >>> is not a user-selected bracket, but the ASCII variant of the C<< «...» >>
[svn:perl6-synopsis] r10380 - doc/trunk/design/syn
Author: audreyt Date: Sun Jul 23 09:53:58 2006 New Revision: 10380 Modified: doc/trunk/design/syn/S02.pod Log: * S02: Typo fixes from Agent Zhang. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podSun Jul 23 09:53:58 2006 @@ -523,7 +523,7 @@ C in question can provide an abstract C interface somehow. Coercion to C should generally invalidate the C interface. As a generic type C may be instantiated as (or bound to) any -of C, C, or C (or to any type that provide the +of C, C, or C (or to any type that provides the appropriate C interface), but when used to create a buffer C defaults to C. @@ -1033,7 +1033,7 @@ Any lexical declared with the C trait is by default considered readonly outside the current lexical scope. You may add C to allow called routines to modify your value. C<$_>, -C<$!> and C<$/> are C by default. In any event, your lexical +C<$!>, and C<$/> are C by default. In any event, your lexical scope can always access the variable as if it were an ordinary C; the restriction on writing applies only to called subroutines. @@ -1759,7 +1759,7 @@ (You are still free to predeclare subroutines explicitly, of course.) The postdeclaration may be in any lexical or package scope that could have made the declaration visible to the provisional call had the -declaration occurred before rather than after than the provisional +declaration occurred before rather than after the provisional call. This fixup is done only for provisional calls. If there @@ -2167,7 +2167,7 @@ infix:<+> $x + $y postfix:<++>$x++ circumfix:<[ ]> [ @x ] -postcircumfix:<[ ]> $x[$y] or $x .[$y] +postcircumfix:<[ ]> $x[$y] or $x.[$y] regex_metachar:<,> /,/ regex_backslash: /\w/ and /\W/ regex_assertion:<*> /<*stuff>/
[svn:perl6-synopsis] r10381 - doc/trunk/design/syn
Author: audreyt Date: Sun Jul 23 10:24:56 2006 New Revision: 10381 Modified: doc/trunk/design/syn/S03.pod Log: * S03: Apply Agent Zhang's patch as well as some more typo fixes. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podSun Jul 23 10:24:56 2006 @@ -170,7 +170,7 @@ SIMPLE OP SIMPLE OP SIMPLE -where C is includes any standard scalar operators in the five +where C includes any standard scalar operators in the five precedence levels autoincrement, exponentiation, symbolic unary, multiplicative, and additive; but these are limited to standard operators that are known to return numbers, strings, or booleans. @@ -383,7 +383,7 @@ Two values are never equivalent unless they are of exactly the same type. By contrast, C always coerces to string, while C<==> always coerces to numeric. In fact, C<$a eq $b> really means "C<~$a === ~$b>" and C<$a == $b> -means "C<+$a === +$b>. +means C<+$a === +$b>. Note also that, while string hashes use C semantics by default, object hashes use C<===> semantics. @@ -442,8 +442,9 @@ really wanted to assign a stringified value.) A negated smart match is spelled C. -=item * "Unary" C<.> calls its single argument (which must a postfix operator) -on C<$_>. (It's not really a unary operator, so we put it in quotes.) +=item * "Unary" C<.> calls its single argument (which must be a postfix +operator) on C<$_>. (It's not really a unary operator, so we put it in +quotes.) =item * The C<..> range operator has variants with C<^> on either end to indicate exclusion of that endpoint from the range. It always @@ -475,7 +476,7 @@ supports the C role. 0..* # 0 .. +Inf -'a'..* # 'a' .. 'z... +'a'..* # 'a' .. 'z...' *..0 # -Inf .. 0 *..* # "-Inf .. +Inf", really Ordered 1.2.3..* # Any version higher than 1.2.3. @@ -569,7 +570,7 @@ Any .method method truth*match if $_.method Any Regex pattern matchmatch if $_ ~~ /$x/ Any subst substitution match* match if $_ ~~ subst -Any boolean simple expression truth* match if true given $_ +Any boolean simple expression truth* match if $x.true given $_ Any undef undefinedmatch unless defined $_ Any Whatever default match anything Any Any run-time dispatchmatch if infix:<~~>($_, $x) @@ -894,7 +895,7 @@ [[;] 1,2,3] # equivalent to [1;2;3] -Builtin reduce operators return the following identity operations: +Builtin reduce operators return the following identity values: [**]() # 1 (arguably nonsensical) [*]() # 1 @@ -933,11 +934,11 @@ [gt]() # Bool::True(also for 1 arg) [ge]() # Bool::True(also for 1 arg) [=:=]() # Bool::True(also for 1 arg) -[!=:=]()# Bool::False(also for 1 arg) +[!=:=]()# Bool::False (also for 1 arg) [===]() # Bool::True(also for 1 arg) -[!===]()# Bool::False(also for 1 arg) +[!===]()# Bool::False (also for 1 arg) [eqv]() # Bool::True(also for 1 arg) -[!eqv]()# Bool::False(also for 1 arg) +[!eqv]()# Bool::False (also for 1 arg) [&&]() # Bool::True [||]() # Bool::False [^^]() # Bool::False @@ -1079,8 +1080,8 @@ my $y := $x; $y = 'Perl Hacker'; -After this, both C<$x> and C<$y> contain the string "Perl Hacker," since -they are really just two different names for the same variable. +After this, both C<$x> and C<$y> contain the string C<"Perl Hacker">, +since they are really just two different names for the same variable. There is another variant, spelled C<::=>, that does the same thing at compile time. @@ -1131,7 +1132,7 @@ my :($b, $c); # okay sub foo :($a,$b) {...} # okay -The C<< -> >> "pointy sub" token also introduces a signature, but +The C<< -> >> "pointy block" token also introduces a signature, but in this case you must omit both the colon and the parens. For instance, if you're defining the "loop variable" of a loop block: @@ -1184,7 +1185,7 @@ =head1 Argument List Interpolating -Perl 5 forced interpolation of a functions argument list by use of +Perl 5 forced interpolation of a function's argument list by use of the C<&> prefix. That option is no longer available
[svn:perl6-synopsis] r10397 - doc/trunk/design/syn
Author: audreyt Date: Mon Jul 24 10:15:19 2006 New Revision: 10397 Modified: doc/trunk/design/syn/S03.pod Log: * S03: Add Agent Zhang's two deltas missed from the previous run. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podMon Jul 24 10:15:19 2006 @@ -808,7 +808,7 @@ my @a = (5,6); [*] @a; # 5 * 6 = 30 -As with the all metaoperators, space is not allowed inside. The whole +As with all the metaoperators, space is not allowed inside. The whole thing parses as a single token. A reduction operator has the same precedence as a list operator. In fact, @@ -1071,7 +1071,7 @@ =head1 Binding -A new form of assignment is present in Perl 6, called "binding," used in +A new form of assignment is present in Perl 6, called I, used in place of typeglob assignment. It is performed with the C<:=> operator. Instead of replacing the value in a container like normal assignment, it replaces the container itself. For instance:
[svn:perl6-synopsis] r10470 - doc/trunk/design/syn
Author: audreyt Date: Tue Jul 25 14:37:31 2006 New Revision: 10470 Modified: doc/trunk/design/syn/S04.pod Log: * S04: CATCH block - grammar and text fix, prompted by gaal++. Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podTue Jul 25 14:37:31 2006 @@ -36,7 +36,7 @@ are three ways to declare formal parameters to a closure. $func = sub ($a, $b) { print if $a eq $b }; # standard sub declaration -$func = -> $a, $b { print if $a eq $b }; # a "pointy" sub +$func = -> $a, $b { print if $a eq $b }; # a "pointy" block $func = { print if $^a eq $^b } # placeholder arguments A bare closure without placeholder arguments that uses C<$_> @@ -456,10 +456,9 @@ of the C block. Handled exceptions break out past this implicit rethrow.) -A C block sees the lexical scope in which it defined, but the -dynamic scope in which it is called, that is, as if it were called -from the dynamic location that threw the exception. That is, the -stack is not unwound until some exception handler chooses to +A C block sees the lexical scope in which it was defined, but +its caller is the dynamic location that threw the exception. That is, +the stack is not unwound until some exception handler chooses to unwind it by "handling" the exception in question. So logically, if the C block throws its own exception, you would expect the C block to catch its own exception recursively forever. However, @@ -495,7 +494,7 @@ return from it. You may only leave the closure block itself with C or by falling off the end of it. -To return a value from a pointy sub or bare closure, you either +To return a value from a pointy block or bare closure, you either just let the block return the value of its final expression, or you can use C. A C by default exits from the innermost block. But you may change the behavior of C with selector adverbs:
[svn:perl6-synopsis] r10477 - doc/trunk/design/syn
Author: audreyt Date: Wed Jul 26 07:17:16 2006 New Revision: 10477 Modified: doc/trunk/design/syn/S02.pod doc/trunk/design/syn/S04.pod doc/trunk/design/syn/S06.pod doc/trunk/design/syn/S09.pod Log: * S02, S04, S06, S09: Chase the terminology change of "pipe operator" => "feed operator" and rename all menitons of pipes in the text. Sometimes a pipe is just a feed... Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podWed Jul 26 07:17:16 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 10 Aug 2004 - Last Modified: 19 July 2006 + Last Modified: 26 July 2006 Number: 2 - Version: 55 + Version: 56 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -571,7 +571,7 @@ A variant of C<*> is the C<**> term. It is generally understood to be a multidimension form of C<*> when that makes sense. -The C<***> variant serves as the insertion point of a list of pipes. +The C<***> variant serves as the insertion point of a list of feeds. That insertion point may be targeted by piping to C<*>. See S06. Other uses for C<*> will doubtless suggest themselves over time. These @@ -734,7 +734,7 @@ constants), the eventual value may well be unknown. All we know is that we have the promise to make the bits of it immutable as they become known. -C objects may contain multiple unresolved iterators such as pipes +C objects may contain multiple unresolved iterators such as feeds or slices. How these are resolved depends on what they are eventually bound to. Some bindings are sensitive to multiple dimensions while others are not. Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podWed Jul 26 07:17:16 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 19 Aug 2004 - Last Modified: 21 July 2006 + Last Modified: 26 July 2006 Number: 4 - Version: 29 + Version: 30 This document summarizes Apocalypse 4, which covers the block and statement syntax of Perl. @@ -503,7 +503,7 @@ The innermost block matching the selection criteria will be exited. The return value, if any, must be passed as a list. To return pairs -as part of the value, you can use a pipe: +as part of the value, you can use a feed operator: leave <== :foo:bar:baz(1) if $leaving; Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podWed Jul 26 07:17:16 2006 @@ -13,9 +13,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 21 Mar 2003 - Last Modified: 16 July 2006 + Last Modified: 26 July 2006 Number: 6 - Version: 40 + Version: 41 This document summarizes Apocalypse 6, which covers subroutines and the @@ -804,10 +804,10 @@ bar;# $args === \(1,2,3) bar(); # $args === \() -=head2 Pipe operators +=head2 Feed operators The variadic list of a subroutine call can be passed in separately -from the normal argument list, by using either of the "pipe" operators: +from the normal argument list, by using either of the I operators: C<< <== >> or C<< ==> >>. Each operator expects to find a call to a variadic receiver on its @@ -819,19 +819,20 @@ It binds the (potentially lazy) list from the blunt end to the slurpy parameter(s) of the receiver on the sharp end. In the case of a receiver -that is a variadic function, the pipe is received as part of its slurpy list. +that is a variadic function, the feed is received as part of its slurpy list. So both of the calls above are equivalent to: grep { $_ % 2 }, @data; -Note that all such pipes (and indeed all lazy argument lists) supply +Note that all such feed (and indeed all lazy argument lists) supply an implicit promise that the code producing the lists may execute -in parallel with the code receiving the lists. (Pipes, hyperops, +in parallel with the code receiving the lists. (Feeds, hyperops, and junctions all have this promise of parallelizability in common, but differ in interface. Code which violates these promises is erroneous, and will produce undefined results when parallelized.) -In particular, a pipeline may not begin and end with the same array. -(You may, however, assign to an array that is used within a pipeline + +In particular, a chain of feeds may not begin and end with the same array. +(You may, however, assign to an array that is used within a chain on the right
[svn:perl6-synopsis] r10478 - doc/trunk/design/syn
Author: audreyt Date: Wed Jul 26 07:21:13 2006 New Revision: 10478 Modified: doc/trunk/design/syn/S04.pod doc/trunk/design/syn/S06.pod Log: * S04, S06: "Pointy sub" and "Pointy block" was used interchangeably in the text, but as uri++ pointed out, it was very confusing as we also say that "return" escapes from subs but not blocks. Hence, rename all mention of "pointy sub" to "pointy block". Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podWed Jul 26 07:21:13 2006 @@ -14,7 +14,7 @@ Date: 19 Aug 2004 Last Modified: 26 July 2006 Number: 4 - Version: 30 + Version: 31 This document summarizes Apocalypse 4, which covers the block and statement syntax of Perl. @@ -488,7 +488,7 @@ A C always exits from the lexically surrounding sub or method definition (that is, from a function officially declared -with the C, C, or C keywords). Pointy subs +with the C, C, or C keywords). Pointy blocks and bare closures are transparent to C. If you pass a closure object outside of its official "sub" scope, it is illegal to return from it. You may only leave the closure block itself with C Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podWed Jul 26 07:21:13 2006 @@ -15,7 +15,7 @@ Date: 21 Mar 2003 Last Modified: 26 July 2006 Number: 6 - Version: 41 + Version: 42 This document summarizes Apocalypse 6, which covers subroutines and the @@ -132,13 +132,13 @@ it is considered the final element of that list unless followed immediately by a comma or comma surrogate. -=head2 "Pointy subs" +=head2 "Pointy blocks" Semantically the arrow operator C<< -> >> is almost a synonym for the anonymous C keyword, except that the parameter list of a -pointy sub does not require parentheses, and a pointy sub may not be -given traits. Syntactically a pointy sub is parsed exactly like a -bare block. +pointy block does not require parentheses, and a pointy block may not be +given traits. Syntactically, a pointy block is parsed exactly like a +bare block: my $sq = -> $val { $val**2 }; say $sq(10); # 100 @@ -149,7 +149,7 @@ } It also behaves like a block with respect to control exceptions. If you -C from within a pointy sub, it will return from the innermost +C from within a pointy block, it will return from the innermost enclosing C or C, not the block itself. It is referenced by C<&?BLOCK>, not C<&?ROUTINE>.
[svn:perl6-synopsis] r10487 - doc/trunk/design/syn
Author: audreyt Date: Wed Jul 26 23:52:24 2006 New Revision: 10487 Modified: doc/trunk/design/syn/S04.pod Log: * S04: Typo fixes form agentzh++, with help from cjeris++ and other kind persons on #perl6. Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podWed Jul 26 23:52:24 2006 @@ -23,7 +23,7 @@ Every block is a closure. (That is, in the abstract, they're all anonymous subroutines that take a snapshot of their lexical scope.) -How any block is invoked and how its results are used is a matter of +How a block is invoked and how its results are used is a matter of context, but closures all work the same on the inside. Blocks are delimited by curlies, or by the beginning and end of the @@ -41,7 +41,7 @@ A bare closure without placeholder arguments that uses C<$_> (either explicitly or implicitly) is treated as though C<$_> were a -a formal parameter: +formal parameter: $func = { print if $_ }; # Same as: $func = -> $_ { print if $_ }; $func("printme"); @@ -473,7 +473,7 @@ cases.) Here "abnormal" means any transfer of control outward that is not just falling off the end of a block. A C, for example, is considered a form of abnormal control flow, since it -can jump out of multiple levels of closure to the end of the scope +can jump out of multiple levels of closures to the end of the scope of the current subroutine definition. Loop commands like C are abnormal, but looping because you hit the end of the block is not. The implicit break of a C block is abnormal. @@ -507,7 +507,7 @@ leave <== :foo:bar:baz(1) if $leaving; -or going the other way:: +or going the other way: $leaving and :foo:bar:baz(1) ==> leave; @@ -521,7 +521,7 @@ scope of that loop, and if that call mentions the outer loop's label, then that outer loop is the one that must be controlled. (This search of lexical scopes is limited to the current "official" subroutine.) -If there is no such lexically scoped outer loop in current subroutine. +If there is no such lexically scoped outer loop in the current subroutine. Then a fallback search is made outward through the dynamic scopes in the same way Perl 5 does. (The difference between Perl 5 and Perl 6 in this respect arises only because Perl 5 didn't have user-defined @@ -568,7 +568,7 @@ of parameters. (Initialization of ordinary variables does not count--presumably the presence of a label will prevent code-movement optimizations past the label.) So, for instance, it's always possible -to goto into the next case of a C or into either the "then" +to C into the next case of a C or into either the "then" or "else" branch of a conditional. You may not go into a C or a C, though, because that would bypass a formal parameter binding (not to mention list generation in the case of C). @@ -580,7 +580,7 @@ As in Perl 5, many built-in functions simply return undef when you ask for a value out of range, or the function fails somehow. Perl 6 has -C objects, which refers to an unthrown C object in +C objects, any of which refers to an unthrown C object in C<$!> and knows whether it has been handled or not. If you test a C for C<.valid>, C<.defined> or C<.true>, it causes @@ -594,11 +594,11 @@ default argument. At scope exit, C<$!> discards all handled exceptions from itself, then performs -a GC check for all remaining (unhandled) exceptions. If all of them are still -alive (e.g. by becoming part of the return value), then they are appended to -C<< CALLER::<$!> >>. Otherwise, it calls C to throw those exceptions -as a single new exception, which may then be caught with a C block in -the current (or caller's) scope. +a garbage-collection check for all remaining (unhandled) exceptions. If all of +them are still alive (e.g. by becoming part of the return value), then they are +appended to C<< CALLER::<$!> >>. Otherwise, it calls C to throw those +exceptions as a single new exception, which may then be caught with a C +block in the current (or caller's) scope. You can cause built-ins to automatically throw exceptions on failure using @@ -672,13 +672,13 @@ All of these trait blocks can see any previously declared lexical variables, even if those variables have not been elaborated yet when -the closure is invoked. (In which case the variables evaluate to an +the closure is invoked (in which case the variables evaluate to an undefined value.) Note: Apocalypse 4 confused the notions of C/C with C/C. These are now separate notions. C and C are used only for their side effects. C and C must return boolean values that are -evaluated according to the usual Design by Contract rules.
[svn:perl6-synopsis] r10488 - doc/trunk/design/syn
Author: audreyt Date: Wed Jul 26 23:53:09 2006 New Revision: 10488 Modified: doc/trunk/design/syn/S02.pod doc/trunk/design/syn/S06.pod Log: * S02 and S06: Markus Laire noted that "piping" shouldn't exist anymore without "pipe operators". Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podWed Jul 26 23:53:09 2006 @@ -572,7 +572,7 @@ be a multidimension form of C<*> when that makes sense. The C<***> variant serves as the insertion point of a list of feeds. -That insertion point may be targeted by piping to C<*>. See S06. +That insertion point may be targeted by sending a feed into C<*>. See S06. Other uses for C<*> will doubtless suggest themselves over time. These can be given meaning via the MMD system, if not the compiler. In general Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podWed Jul 26 23:53:09 2006 @@ -872,8 +872,8 @@ foo() ==> say ***, " is what I meant"; bar() ==> ***.baz(); -Piping to the C<*> "whatever" term is considered a feed to the lexically -following C<***> term: +Sending a feed into the C<*> "whatever" term is considered to extend +the lexically following C<***> term: 0..* ==> *; 'a'..* ==> *;
[svn:perl6-synopsis] r10490 - doc/trunk/design/syn
Author: audreyt Date: Thu Jul 27 10:38:08 2006 New Revision: 10490 Modified: doc/trunk/design/syn/S02.pod doc/trunk/design/syn/S06.pod Log: * S02, S06: gaal++ suggested s/sending a feed into/feeding into/. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podThu Jul 27 10:38:08 2006 @@ -572,7 +572,7 @@ be a multidimension form of C<*> when that makes sense. The C<***> variant serves as the insertion point of a list of feeds. -That insertion point may be targeted by sending a feed into C<*>. See S06. +That insertion point may be targeted by feeding into C<*>. See S06. Other uses for C<*> will doubtless suggest themselves over time. These can be given meaning via the MMD system, if not the compiler. In general Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podThu Jul 27 10:38:08 2006 @@ -872,8 +872,8 @@ foo() ==> say ***, " is what I meant"; bar() ==> ***.baz(); -Sending a feed into the C<*> "whatever" term is considered to extend -the lexically following C<***> term: +Feeding into the C<*> "whatever" term will extend the lexically +following C<***> term: 0..* ==> *; 'a'..* ==> *;
[svn:perl6-synopsis] r10492 - doc/trunk/design/syn
Author: audreyt Date: Thu Jul 27 10:44:22 2006 New Revision: 10492 Modified: doc/trunk/design/syn/S04.pod Log: * S04: More nits from agentzh++. (However, the period-inside-parens style, as seen in this sentence, is not changed.) Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podThu Jul 27 10:44:22 2006 @@ -23,7 +23,7 @@ Every block is a closure. (That is, in the abstract, they're all anonymous subroutines that take a snapshot of their lexical scope.) -How a block is invoked and how its results are used is a matter of +How a block is invoked and how its results are used are matters of context, but closures all work the same on the inside. Blocks are delimited by curlies, or by the beginning and end of the @@ -225,7 +225,7 @@ However, that's likely to be visually confused with a following C loop at the best of times, so it's also allowed to put the -loop conditional at the front, with the same meaning (the C +loop conditional at the front, with the same meaning. (The C keyword forces the conditional to be evaluated at the end of the loop, so it's still C's do-while semantics.) Therefore, even under GNU style rules, the previous example may be rewritten into a very clear: @@ -521,8 +521,9 @@ scope of that loop, and if that call mentions the outer loop's label, then that outer loop is the one that must be controlled. (This search of lexical scopes is limited to the current "official" subroutine.) -If there is no such lexically scoped outer loop in the current subroutine. -Then a fallback search is made outward through the dynamic scopes in + +If there is no such lexically scoped outer loop in the current subroutine, +then a fallback search is made outward through the dynamic scopes in the same way Perl 5 does. (The difference between Perl 5 and Perl 6 in this respect arises only because Perl 5 didn't have user-defined control structures, hence the sub's lexical scope was I
[svn:perl6-synopsis] r10780 - doc/trunk/design/syn
Author: audreyt Date: Thu Aug 10 09:16:15 2006 New Revision: 10780 Modified: doc/trunk/design/syn/S02.pod Log: * S02: Add a infix_prefix_meta_operator grammatical category to carry the generic chain-associative negation modifier "!". Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podThu Aug 10 09:16:15 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 10 Aug 2004 - Last Modified: 9 Aug 2006 + Last Modified: 10 Aug 2006 Number: 2 - Version: 61 + Version: 62 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -2215,6 +2215,7 @@ scope_declarator: has $.x; statement_control: if $condition {...} else {...} statement_modifier: ... if $condition +infix_prefix_meta_operator: $x !~~ 2; infix_postfix_meta_operator:<=> $x += 2; postfix_prefix_meta_operator:{'»'} @array »++ prefix_postfix_meta_operator:{'«'} -« @magnitudes
[svn:perl6-synopsis] r10782 - doc/trunk/design/syn
Author: audreyt Date: Thu Aug 10 09:35:52 2006 New Revision: 10782 Modified: doc/trunk/design/syn/S04.pod Log: * S04: Clarify that the following forms are hash composers: $h = {}; $h = {%h}; * Also change the archaic $coderef etc in examples to simply $code. Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podThu Aug 10 09:35:52 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 19 Aug 2004 - Last Modified: 9 Aug 2006 + Last Modified: 11 Aug 2006 Number: 4 - Version: 32 + Version: 33 This document summarizes Apocalypse 4, which covers the block and statement syntax of Perl. @@ -741,30 +741,34 @@ operator is expected. (Remove the whitespace if you wish it to be a postcircumfix.) -Anywhere a term is expected, a block is taken to -be a closure definition (an anonymous subroutine). If the closure -appears to delimit nothing but a comma-separated list starting with -a pair (counting a single pair as a list of one element), the closure -will be immediately executed as a hash composer. - -$hashref = { "a" => 1 }; -$hashref = { "a" => 1, $b, $c, %stuff, @nonsense }; - -$coderef = { "a", 1 }; -$coderef = { "a" => 1, $b, $c ==> print }; +Anywhere a term is expected, a block is taken to be a closure definition +(an anonymous subroutine). If the closure is empty, or appears to contain +nothing but a comma-separated list starting with a pair or a hash (counting +a single pair or hash as a list of one element), the closure will be +immediately executed as a hash composer. + +$hash = { }; +$hash = { %stuff }; +$hash = { "a" => 1 }; +$hash = { "a" => 1, $b, $c, %stuff, @nonsense }; + +$code = { ; }; +$code = { @stuff }; +$code = { "a", 1 }; +$code = { "a" => 1, $b, $c ==> print }; If you wish to be less ambiguous, the C list operator will explicitly evaluate a list and compose a hash of the returned value, while C introduces an anonymous subroutine: -$coderef = sub { "a" => 1 }; -$hashref = hash("a" => 1); -$hashref = hash("a", 1); +$code = sub { "a" => 1 }; +$hash = hash("a" => 1); +$hash = hash("a", 1); If a closure is the right argument of the dot operator, the closure is interpreted as a hash subscript. -$ref = {$x}; # closure because term expected +$code = {$x}; # closure because term expected if $term{$x} # subscript because postfix expected if $term {$x} # expression followed by statement block if $term.{$x} # valid subscript with dot @@ -772,7 +776,7 @@ Similar rules apply to array subscripts: -$ref = [$x]; # array composer because term expected +$array = [$x]; # array composer because term expected if $term[$x] # subscript because postfix expected if $term [$x] # syntax error (two terms in a row) if $term.[$x] # valid subscript with dot @@ -780,7 +784,7 @@ And to the parentheses delimiting function arguments: -$ref = ($x); # grouping parens because term expected +$scalar = ($x);# grouping parens because term expected if $term($x) # function call because operator expected if $term ($x) # syntax error (two terms in a row) if $term.($x) # valid function call with dot @@ -889,7 +893,7 @@ my $x = 1; my sub bar { print $x } # not cloned yet my &baz = { bar(); print $x }; # cloned immediately - my $barref = &bar; # now bar is cloned + my $code = &bar;# now bar is cloned return &baz; }
[svn:perl6-synopsis] r10783 - doc/trunk/design/syn
Author: audreyt Date: Thu Aug 10 09:40:48 2006 New Revision: 10783 Modified: doc/trunk/design/syn/S03.pod doc/trunk/design/syn/S06.pod Log: * S03: Signature ~~ Signature now tests for compatibility, i.e. whether if anything that can bind to LHS can also bind to RHS. * S06: The "want" function now returns a Signature object, instead of a "Context" object with vaguely defined pseudo-class methods. This also unifies the calling convention with the returning convention. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podThu Aug 10 09:40:48 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 8 Mar 2004 - Last Modified: 9 Aug 2006 + Last Modified: 11 Aug 2006 Number: 3 - Version: 54 + Version: 55 =head1 Changes to Perl 5 operators @@ -562,7 +562,9 @@ Num NumRange in numeric range match if $min <= $_ <= $max Str StrRange in string range match if $min le $_ le $max Capture Signature parameter bindingmatch if $cap can bind to $sig -Any Code:()simple closure truth*match if $x() (ignoring $_) +CodeSignature signature compatibility* match if $_ is a subset of $x + Signature Signature signature compatibility match if $_ is a subset of $x +Any Code:() simple closure truth*match if $x() (ignoring $_) Any Class class membership match if $_.does($x) Any Role role playing match if $_.does($x) Any Num numeric equality match if $_ == $x Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podThu Aug 10 09:40:48 2006 @@ -1763,6 +1763,10 @@ Specifies that the parameter cannot be modified (e.g. assigned to, incremented). It is the default for parameters. +$x = 5; + +sub f ($x) {} + =item C Specifies that the parameter can be modified (assigned to, incremented, @@ -1880,35 +1884,35 @@ =head2 The C function -The C function returns an object that contains information about -the context in which the current block, closure, or subroutine was +The C function returns a C object that contains information +about the context in which the current block, closure, or subroutine was called. -The returned context object is typically tested with a smart match (C<~~>) -or a C: +As with normal function signatures, you can test the result of C with a +smart match (C<~~>) or a C: given want { -when Scalar {...} # called in scalar context -when List {...} # called in list context -when Lvalue {...} # expected to return an lvalue -when 2 {...} # expected to return two values +when :($) {...} # called in scalar context +when :(*@) {...} # called in list context +when :($ is rw) {...} # expected to return an lvalue +when :($,$) {...} # expected to return two values ... } -or has the corresponding methods called on it: +You can also use the postfix signature syntax to test for compatibility: + +ifwant:($) {...} # called in scalar context +elsif want:(*@) {...} # called in list context +elsif want:($ is rw) {...} # expected to return an lvalue +elsif want:($,$) {...} # expected to return two values + +The C<.arity> method also works here: -if(want.Scalar){...}# called in scalar context -elsif (want.List) {...}# called in list context -elsif (want.rw){...}# expected to return an lvalue -elsif (want.count > 2) {...}# expected to return more than two values - -Note these are pseudo type associations. There's no such thing as an -Lvalue object, and a List is really an unbound argument list object, -parts of which may in fact be eventually bound into scalar context. +if want.arity > 2{...} # expected to return more than two values =head2 The C function -A C statement causes the innermost surrounding subroutine, +A C call causes the innermost surrounding subroutine, method, rule, token, regex (as a keyword), macro, or multimethod to return. Only declarations with an explicit keyword such as "sub" may be returned from. You may not return from a quotelike operator such
[svn:perl6-synopsis] r10805 - doc/trunk/design/syn
Author: audreyt Date: Thu Aug 10 19:18:48 2006 New Revision: 10805 Modified: doc/trunk/design/syn/S02.pod doc/trunk/design/syn/S03.pod Log: * Two small typo fix: "value-bases comparison" -> "value-based comparison" "Storeable" -> "Storable" Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podThu Aug 10 19:18:48 2006 @@ -440,7 +440,7 @@ Some object types can behave as value types. Every object can produce a "safe key identifier" (C for short) that uniquely identifies the -object for hashing and other value-bases comparisons. Normal objects +object for hashing and other value-based comparisons. Normal objects just use their address in memory, but if a class wishes to behave as a value type, it can define a C<.SKID> method that makes different objects look like the same object if they happen to have the same contents. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podThu Aug 10 19:18:48 2006 @@ -584,15 +584,15 @@ reversible by putting the leading term into a closure to defer the binding of C<$_>. For example: -$x ~~ .does(Storeable) # okay -.does(Storeable) ~~ $x # not okay--gets wrong $_ on left -{ .does(Storeable) } ~~ $x # okay--closure binds its $_ to $x +$x ~~ .does(Storable) # okay +.does(Storable) ~~ $x # not okay--gets wrong $_ on left +{ .does(Storable) } ~~ $x # okay--closure binds its $_ to $x Exactly the same consideration applies to C and C: -given $x { when .does(Storeable) {...} } # okay -given .does(Storeable) { when $x {...} } # not okay -given { .does(Storeable) } { when $x {...} } # okay +given $x { when .does(Storable) {...} } # okay +given .does(Storable) { when $x {...} } # not okay +given { .does(Storable) } { when $x {...} } # okay Boolean expressions are those known to return a boolean value, such as comparisons, or the unary C operator. They may reference C<$_>
[svn:perl6-synopsis] r10855 - doc/trunk/design/syn
Author: audreyt Date: Fri Aug 11 20:28:03 2006 New Revision: 10855 Modified: doc/trunk/design/syn/S06.pod Log: * S06: dconway++ suggested that we still provide convenience methods on Signature level, to reduce line noise in common "want" operations. * Also remove a stray paragraph miscommitted with the previous commit. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podFri Aug 11 20:28:03 2006 @@ -13,9 +13,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 21 Mar 2003 - Last Modified: 11 Aug 2006 + Last Modified: 12 Aug 2006 Number: 6 - Version: 47 + Version: 48 This document summarizes Apocalypse 6, which covers subroutines and the @@ -1766,10 +1766,6 @@ Specifies that the parameter cannot be modified (e.g. assigned to, incremented). It is the default for parameters. -$x = 5; - -sub f ($x) {} - =item C Specifies that the parameter can be modified (assigned to, incremented, @@ -1902,16 +1898,24 @@ ... } -You can also use the postfix signature syntax to test for compatibility: +Or use its shorthand methods to reduce line noise: + +ifwant.item {...} # called in non-lvalue scalar context +elsif want.list {...} # called in list context +elsif want.void {...} # called in void context +elsif want.rw{...} # expected to return an lvalue + +The C<.arity> and C<.count> methods also work here: -ifwant:($) {...} # called in scalar context -elsif want:(*@) {...} # called in list context -elsif want:($ is rw) {...} # expected to return an lvalue -elsif want:($,$) {...} # expected to return two values +if want.arity > 2{...} # must return more than two values +if want.count > 2{...} # can return more than two values -The C<.arity> method also works here: +Their difference is that C<.arity> considers only mandatory parts, +while C<.count> considers also optional ones, including C<*$>: -if want.arity > 2{...} # expected to return more than two values +($x, $y) = f(); # Within &f, want === :(*$?, *$?, *@) +#want.arity === 0 +#want.count === 2 =head2 The C function
[svn:perl6-synopsis] r11135 - doc/trunk/design/syn
Author: audreyt Date: Fri Aug 18 08:11:42 2006 New Revision: 11135 Modified: doc/trunk/design/syn/S06.pod doc/trunk/design/syn/S13.pod Log: * S13 and S06: Remove the mentioning of "invocants" for multi dispatch; they are now simply "parameters", or "important parameters" for dispatch purposes. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podFri Aug 18 08:11:42 2006 @@ -13,9 +13,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 21 Mar 2003 - Last Modified: 17 Aug 2006 + Last Modified: 18 Aug 2006 Number: 6 - Version: 50 + Version: 51 This document summarizes Apocalypse 6, which covers subroutines and the @@ -54,7 +54,7 @@ B (keyword: C) are routines that can have multiple variants that share the same name, selected by arity, types, or some -other constraints. They may have multliple invocants. +other constraints. B (keyword: C) specify the commonalities (such as parameter names, fixity, and associativity) shared by all multis @@ -498,10 +498,10 @@ # fall-back to set_name($obj, "Sam") $obj.set_name("Sam"); # same as the above -An invocant is the topic of the corresponding method or multi if that -formal parameter is declared with the name C<$_>. A method's first -invocant always has the alias C. Other styles of self can be -declared with the C pragma. +An invocant is the topic of the corresponding method if that formal +parameter is declared with the name C<$_>. A method's first invocant +always has the alias C. Other styles of self can be declared +with the C pragma. =head2 Longname parameters @@ -515,9 +515,9 @@ multi method set_name ($self: $name; $nick) {...} If the parameter list for a C contains no semicolon to delimit -the list of invocant parameters, then all positional parameters are -considered invocants. If it's a C or C, -an additional implicit unnamed C invocant is prepended to the +the list of important parameters, then all positional parameters are +considered important. If it's a C or C, +an additional implicit unnamed C invocant is added to the signature list unless the first parameter is explicitly marked with a colon. @@ -2148,7 +2148,7 @@ This special form should generally be restricted to named parameters. To curry a particular multimethod it may be necessary to specify the type -of one or more of its invocants: +for one or more of its parameters: &woof ::= &bark:(Dog).assuming :pitch; &pine ::= &bark:(Tree).assuming :pitch; Modified: doc/trunk/design/syn/S13.pod == --- doc/trunk/design/syn/S13.pod(original) +++ doc/trunk/design/syn/S13.podFri Aug 18 08:11:42 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 2 Nov 2004 - Last Modified: 1 Apr 2006 + Last Modified: 18 Aug 2006 Number: 13 - Version: 4 + Version: 5 =head1 Overview @@ -53,11 +53,10 @@ rather than the built-in one. Putting the C into the C<*> namespace makes it show up in everyone's packages, but as long as no one else defines a version of C on C, there's no collision. -The types of the invocants are included in the "long name" of any C -sub or method. -If you want to overload string concatenation for Arabic strings -so you can handle various ligatures, you can say: +The types of the parameters are included in the I of any C +sub or method. So if you want to overload string concatenation for Arabic +strings so you can handle various ligatures, you can say: multi sub *infix:<~>(ArabicStr $s1, ArabicStr $s2) {...} multi sub *infix:<~>(Str $s1, ArabicStr $s2) {...}
[svn:perl6-synopsis] r11509 - doc/trunk/design/syn
Author: audreyt Date: Mon Aug 28 00:11:57 2006 New Revision: 11509 Modified: doc/trunk/design/syn/S02.pod Log: * grammar nit, and clarify that it is the assign-to-scalar that Arrayify a list. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podMon Aug 28 00:11:57 2006 @@ -1412,7 +1412,8 @@ $a = ('a','b'); -which, because the list is in scalar context, is autopromoted an Array object: +which, because the list is assigned to a scalar, is autopromoted into +an Array object: $a = ['a','b'];
[svn:perl6-synopsis] r11527 - doc/trunk/design/syn
Author: audreyt Date: Mon Aug 28 07:34:29 2006 New Revision: 11527 Modified: doc/trunk/design/syn/S02.pod Log: * S02: minor grammar and syntax nit from p6l feedbacks. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podMon Aug 28 07:34:29 2006 @@ -1396,13 +1396,17 @@ When used as a subscript it performs a slice equivalent to C<{'foo','bar'}>. Elsewhere it is equivalent to a parenthesisized list of strings: C<< ('foo','bar') >>. Since parentheses are generally reserved just for -precedence grouping, they merely autointepolate in list context. Therefore +precedence grouping, they merely autointerpolate in list context. Therefore -@a = 1, < 2 3 >, 4; +@a = 1, < x y >, 2; -is equivalent to +is equivalent to: + +@a = 1, ('x', 'y'), 2; + +which is the same as: -@a = 1, 2, 3, 4; +@a = 1, 'x', 'y', 2; In scalar context, though, the implied parentheses are not removed, so @@ -1410,12 +1414,12 @@ is equivalent to: -$a = ('a','b'); +$a = ('a', 'b'); which, because the list is assigned to a scalar, is autopromoted into an Array object: -$a = ['a','b']; +$a = ['a', 'b']; Likewise, if bound to a scalar parameter, C<< >> will be treated as a single list object, but if bound to a slurpy parameter,
[svn:perl6-synopsis] r11725 - doc/trunk/design/syn
Author: audreyt Date: Sun Sep 3 10:04:00 2006 New Revision: 11725 Modified: doc/trunk/design/syn/S03.pod Log: * S03: Clarify that this: my Dog ($x, $y) really means the same as: my (Dog $x, Dog $y) Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podSun Sep 3 10:04:00 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 8 Mar 2004 - Last Modified: 16 Aug 2006 + Last Modified: 4 Sep 2006 Number: 3 - Version: 56 + Version: 57 =head1 Changes to Perl 5 operators @@ -1117,6 +1117,12 @@ my ($b, $c); # okay my $b, $c; # wrong: "Use of undeclared variable: $c" +Types occuring between the declarator and the signature are distributed into +each variable: + +my Dog ($b, $c); +my (Dog $b, Dog $c);# same thing + [XXX the following probably belongs in S06.] The syntax for constructing a C object when the parser isn't already expecting one is:
[svn:perl6-synopsis] r11817 - doc/trunk/design/syn
Author: audreyt Date: Thu Sep 7 07:07:43 2006 New Revision: 11817 Modified: doc/trunk/design/syn/S04.pod Log: 16:06 < agentzh> audreyt: could you fix the "modifer" typo in S04 for me? :) Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podThu Sep 7 07:07:43 2006 @@ -331,7 +331,7 @@ so you can modify the current list element in that case. However, any time you specify the arguments, they default to read only. -When used as statement modifers, C and C use a private +When used as statement modifiers, C and C use a private instance of C<$_> for the left side of the statement. The outer C<$_> can be referred to as C<$OUTER::_>. (And yes, this implies that the compiler may have to retroactively change the binding of <$_> on the
[svn:perl6-synopsis] r11974 - doc/trunk/design/syn
Author: audreyt Date: Tue Sep 12 19:35:59 2006 New Revision: 11974 Modified: doc/trunk/design/syn/S03.pod Log: * S03: Typographical and stylistic cleanups. Also, clarify that identity values of reduce hyperoperators is more logically defined by the way of a multi variant of zero arity, rather than specifying it inside the proto itself. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podTue Sep 12 19:35:59 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 8 Mar 2004 - Last Modified: 12 Sep 2006 + Last Modified: 13 Sep 2006 Number: 3 - Version: 60 + Version: 61 =head1 Changes to Perl 5 operators @@ -50,7 +50,7 @@ a boolean (C) context, and the C<[,]> list operator imposes a function-arguments (C) context on its arguments. Unary sigils impose the container context implied by their sigil. -As with Perl 5, however, C<$$foo[bar]> parses as C<$($foo)[bar]>, +As with Perl 5, however, C<$$foo[bar]> parses as C<( $($foo) )[bar]>, so you need C<$($foo[bar])> to mean the other way. =item * Bitwise operators get a data type prefix: C<+>, C<~>, or C. @@ -543,7 +543,7 @@ $_ $xType of Match ImpliedMatching Code == = == -Any Code:($) scalar sub truth match if $x($_) +Any Code:($) scalar sub truth match if $x($_) HashHash hash keys identical match if $_.keys.sort »eq« $x.keys.sort Hashany(Hash) hash key intersectionmatch if $_{any(Hash.keys)} HashArray hash value slice truth match if $_{any(@$x)} @@ -602,7 +602,7 @@ you can't write: given $boolean { - when True {...} + when True {...} when False {...} } @@ -610,7 +610,7 @@ given $boolean { when .true {...} - when .not {...} + when .not {...} } Better, just use an C statement. @@ -648,7 +648,7 @@ metaoperations--their semantics are supposed to be self-evident by the transformation of the base operator. -Note: spaces are never allowed between any metaoperator and the +Note: Spaces are never allowed between any metaoperator and the operator it's modifying, because all operators including modified ones have to be recognized by the Longest-Token Rule, which disallows spaces within a token. @@ -672,7 +672,7 @@ of any assignment operators is forced to be the same as that of ordinary assignment. -=head2 Negated relational operators. +=head2 Negated relational operators Any infix relational operator may be transformed into its negative by prefixing with C. A couple of these have traditional shortcuts: @@ -720,7 +720,7 @@ In fact, this is the I form that will work for an unordered type such as a C: - Bag(3,8,2,9,3,8) >>-<< 1; # Bag(2,7,1,8,2,7) ~~ Bag(1,2,2,7,7,8) + Bag(3,8,2,9,3,8) >>-<< 1; # Bag(2,7,1,8,2,7) === Bag(1,2,2,7,7,8) When using a unary operator, only put the "hyper" on the side of the single operand: @@ -870,11 +870,15 @@ multi prefix:<[foo]> (Int $x) { 42 } multi prefix:<[foo]> (Str $x) { fail "Can't foo a single Str" } -However, the zero argument case must of necessity be handled by the -proto version, since there is no type information to dispatch on. -Operators that wish to specify an identity value should do so by -specifying the proto listop. Among the builtin operators, C<[+]()> -returns 0 and C<[*]()> returns 1, for instance. +However, the zero argument case cannot be defined this way, since there +is no type information to dispatch on. Operators that wish to specify an +identity value should do so by specifying a multi variant that takes zero +arguments: + +multi prefix:<[foo]> () { 0 } + +Among the builtin operators, C<[+]()> returns 0 and C<[*]()> returns 1, +for instance. By default, if there is one argument, the built-in reduce operators return that one argument. However, this default doesn't make sense
[svn:perl6-synopsis] r12239 - doc/trunk/design/syn
Author: audreyt Date: Wed Sep 20 02:41:02 2006 New Revision: 12239 Modified: doc/trunk/design/syn/S06.pod Log: * S06: As &code.call() is specified to take one single Capture argument, fix the example in which the argument was erroneously flattened. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podWed Sep 20 02:41:02 2006 @@ -13,9 +13,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 21 Mar 2003 - Last Modified: 13 Sept 2006 + Last Modified: 20 Sept 2006 Number: 6 - Version: 54 + Version: 55 This document summarizes Apocalypse 6, which covers subroutines and the @@ -2124,7 +2124,7 @@ C object by passing the C to its C method: # Transparently redirect all calls to &thermo to &other_thermo -&thermo.wrap( -> \$args { &other_thermo.call([,] =$args) } ); +&thermo.wrap( -> \$args { &other_thermo.call($args) } ); Outside a wrapper, C implicitly calls the next-most-likely method or multi-sub; see S12 for details.
[svn:perl6-synopsis] r12246 - doc/trunk/design/syn
Author: audreyt Date: Wed Sep 20 03:22:42 2006 New Revision: 12246 Modified: doc/trunk/design/syn/S06.pod Log: * S06: TreyHarris++ pointed out another slurpy-star legacy. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podWed Sep 20 03:22:42 2006 @@ -15,7 +15,7 @@ Date: 21 Mar 2003 Last Modified: 20 Sept 2006 Number: 6 - Version: 55 + Version: 56 This document summarizes Apocalypse 6, which covers subroutines and the @@ -2118,7 +2118,7 @@ It can then be passed to C as C<*$args>: # Double the return value for &thermo -&thermo.wrap( -> \$args { call(*$args) * 2 } ); +&thermo.wrap( -> \$args { call([,] =$args) * 2 } ); The wrapper is not required to call the original routine; it can call another C object by passing the C to its C method:
[svn:perl6-synopsis] r12247 - doc/trunk/design/syn
Author: audreyt Date: Wed Sep 20 03:27:09 2006 New Revision: 12247 Modified: doc/trunk/design/syn/S06.pod Log: * Ditto. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podWed Sep 20 03:27:09 2006 @@ -2115,7 +2115,7 @@ temp &thermo.wrap( { call($^t + 273.16) } ); The entire argument list may be captured by the C<\$args> parameter. -It can then be passed to C as C<*$args>: +It can then be passed to C as C<[,] =$args>: # Double the return value for &thermo &thermo.wrap( -> \$args { call([,] =$args) * 2 } );
[svn:perl6-synopsis] r12346 - doc/trunk/design/syn
Author: audreyt Date: Sat Sep 23 01:05:45 2006 New Revision: 12346 Modified: doc/trunk/design/syn/S03.pod Log: * S03: Cleanup capture-exploding examples such that |@foo always simply put @foo's elements as positional arguments, regardless of whether @foo[0] contains a Hash. (On the other hand, "[,] @foo" will still happily turn @foo[0] into named argument.) Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podSat Sep 23 01:05:45 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 8 Mar 2004 - Last Modified: 20 Sept 2006 + Last Modified: 23 Sept 2006 Number: 3 - Version: 67 + Version: 68 =head1 Changes to Perl 5 operators @@ -911,7 +911,7 @@ as if they'd been placed there directly. @args = [EMAIL PROTECTED],1,2,3; -push [,] @args;# same as push @foo,1,2,3 +push [,] @args;# same as push(@foo: 1,2,3) See S06 for more. @@ -1311,33 +1311,39 @@ is equivalent to: -push @foo, @bar; +push @foo: @bar; -as is this: +which is just another way to write: -my $args = \(@foo, @bar);# construct a Capture object -push |$args; +@foo.push(@bar); -The C<|> sigil functions as a unary form of the C<[,]> -list operator, so we could have written the earlier example as: +The C<|> sigil functions as a unary form of the C<[,]> list operator, +so the examples above can also be written as. -my @args = [EMAIL PROTECTED], @bar; -push |@args; +my $args = \(@foo: @bar); # construct a Capture object +push |$args;# push(@foo: @bar) + +Unlike C<[,]>, C<|> does not flatten its argument, but instead directly +converts its argument into a C: + +my @args = \$x, 1, 2, 3; +say [,] @args; # say($x: 1, 2, 3); +say |@args; # say(\$x, 1, 2, 3); -To the extent possible, the C<|> will treat its argument as -a C even if it isn't. +Because of this, C<|%args> always produces named arguments, and +C<|@args> always produces positional arguments. In list context, a C holding an C object does not flatten. Hence $bar = @bar; -push @foo, $bar; +@foo.push($bar); merely pushes a single C object onto C<@foo>. You can explicitly flatten it in one of these ways: -push @foo, @$bar; -push @foo, $bar[]; -push @foo, |$bar; +@foo.push(@$bar); +@foo.push($bar[]); +@foo.push(|$bar); Those three forms work because the slurpy array in C's signature flattens the C object into a list argument. @@ -1382,7 +1388,7 @@ automatically exploded into their various parts, as if you'd said: my \$capture := func(); -push [,] $$capture: @$capture, %$capture; +push($$capture: @$capture, %$capture); or some such. The C<[,]> then handles the various zones appropriately depending on the context. An invocant only makes sense as the first
[svn:perl6-synopsis] r12347 - doc/trunk/design/syn
Author: audreyt Date: Sat Sep 23 20:48:58 2006 New Revision: 12347 Modified: doc/trunk/design/syn/S04.pod Log: * S04: Wording and examples cleanup; no semantic changes. Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podSat Sep 23 20:48:58 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 19 Aug 2004 - Last Modified: 15 Sep 2006 + Last Modified: 24 Sep 2006 Number: 4 - Version: 39 + Version: 40 This document summarizes Apocalypse 4, which covers the block and statement syntax of Perl. @@ -869,7 +869,7 @@ Final blocks on statement-level constructs always imply semicolon precedence afterwards regardless of the position of the closing curly. Statement-level constructs are distinguished in the grammar by being -declared in the statement syntactic group: +declared in the C category: macro statement_control: ($expr, &ifblock) {...} macro statement_control: ($expr, &whileblock) {...} @@ -879,8 +879,8 @@ the start of a statement. To embed a statement in an expression you must use something like C or C. -$x = do { given $foo { when 1 {2} when 3 {4} }} + $bar; -$x = try { given $foo { when 1 {2} when 3 {4} }} + $bar; +$x = do { given $foo { when 1 {2} when 3 {4} } } + $bar; +$x = try { given $foo { when 1 {2} when 3 {4} } } + $bar; The existence of a C<< statement_control: >> does not preclude us from also defining a C<< prefix: >> that I be used within an expression: @@ -895,7 +895,7 @@ You could also conceivably define a C<< prefix: >>, but then you may not get what you want when you say: -.print if $foo; +die if $foo; since C<< prefix: >> would hide C<< statement_modifier: >>.
[svn:perl6-synopsis] r12348 - doc/trunk/design/syn
Author: audreyt Date: Sun Sep 24 06:12:58 2006 New Revision: 12348 Modified: doc/trunk/design/syn/S06.pod Log: * S06: Squash two remaining "*f" into "|(f)". Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podSun Sep 24 06:12:58 2006 @@ -13,9 +13,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 21 Mar 2003 - Last Modified: 22 Sept 2006 + Last Modified: 24 Sept 2006 Number: 6 - Version: 57 + Version: 58 This document summarizes Apocalypse 6, which covers subroutines and the @@ -1891,11 +1891,11 @@ responds to the left-hand C in a binding. This allows named return values if the caller expects one: -sub f { return :x<1> } +sub f () { return :x<1> } sub g ($x) { print $x } -my $x := *f(); # binds 1 to $x, via a named argument -g(*f());# prints 1, via a named argument +my $x := |(f); # binds 1 to $x, via a named argument +g(|(f));# prints 1, via a named argument To return a literal C object, always put it in an additional set of parentheses:
[svn:perl6-synopsis] r12417 - doc/trunk/design/syn
Author: audreyt Date: Mon Sep 25 20:49:59 2006 New Revision: 12417 Modified: doc/trunk/design/syn/S02.pod doc/trunk/design/syn/S04.pod Log: * S02: Introduce the :$$x form in adverbial pair parsing. * S02/S04: Canonicalize "item" as the unary context enforcer, so that the name "Scalar" can unabiguous mean the mutable container class. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podMon Sep 25 20:49:59 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 10 Aug 2004 - Last Modified: 25 Sept 2006 + Last Modified: 26 Sept 2006 Number: 2 - Version: 72 + Version: 73 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -1481,6 +1481,8 @@ a => $a:$a a => @a:@a a => %a:%a +a => $$a :$$a +a => @$$a :@$$a (etc.) a => %foo %foo: Note that as usual the C<{...}> form can indicate either a closure or a hash @@ -2142,6 +2144,8 @@ really does exactly the same thing as putting a list in parentheses with at least one comma. But it's more readable in some situations.) +To force a non-flattening scalar context, use the "C" operator. + =item * The C<|> prefix operator may be used to force "capture" context on its Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podMon Sep 25 20:49:59 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 19 Aug 2004 - Last Modified: 24 Sep 2006 + Last Modified: 26 Sep 2006 Number: 4 - Version: 40 + Version: 41 This document summarizes Apocalypse 4, which covers the block and statement syntax of Perl. @@ -933,7 +933,7 @@ and not care about whether the function is being called in scalar or list context. To return an explicit scalar undef, you can always say -return scalar(undef); +return item(undef); Then in list context, you're returning a list of length 1, which is defined (much like in Perl 5). But generally you should be using
[svn:perl6-synopsis] r12432 - doc/trunk/design/syn
Author: audreyt Date: Tue Sep 26 03:07:20 2006 New Revision: 12432 Modified: doc/trunk/design/syn/S03.pod Log: * S03: Document that chained comparisons short-circuit, and never evaluates its arguments more than once. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podTue Sep 26 03:07:20 2006 @@ -1151,7 +1151,7 @@ =head1 Chained comparisons Perl 6 supports the natural extension to the comparison operators, -allowing multiple operands. +allowing multiple operands: if 1 < $a < 100 { say "Good, you picked a number *between* 1 and 100." } @@ -1159,6 +1159,14 @@ if 1 <= $roll1 == $roll2 <= 6 { print "Doubles!" } +A chain of comparisons short-circuits if the first comparison fails: + +1 > 2 > die("this is never reached"); + +Each argument in the chain will evaluate at most once: + +1 > $x++ > 2# $x increments exactly once + Note: any operator beginning with C<< < >> must have whitespace in front of it, or it will be interpreted as a hash subscript instead.
[svn:perl6-synopsis] r12531 - doc/trunk/design/syn
Author: audreyt Date: Sat Sep 30 20:13:47 2006 New Revision: 12531 Modified: doc/trunk/design/syn/S09.pod Log: * S09: any() no longer has anything to do with comprehension. Modified: doc/trunk/design/syn/S09.pod == --- doc/trunk/design/syn/S09.pod(original) +++ doc/trunk/design/syn/S09.podSat Sep 30 20:13:47 2006 @@ -603,22 +603,6 @@ in fact scalar parameters, though, so you could pass a junction of array or hash objects.) -For junctions used with chained operators in a list context, the resulting -value will be a subset of the first C used in comparison: - -for 0 <= any(@x) < all(@y) {...} - -will use only those values from C<@x> that satisfy the constraint. -Usually junctions do not guarantee order of evalution, but in -this particular case, the original ordering C<@x> is guaranteed to -be preserved in the returned list. In particular, - -@result = any(@x) ~~ {...}; - -is equivalent to - -@result = grep {...}, @x; - =head1 Parallelized parameters and autothreading Within the scope of a C pragma (or equivalent, such as
[svn:perl6-synopsis] r12533 - doc/trunk/design/syn
Author: audreyt Date: Sat Sep 30 20:16:38 2006 New Revision: 12533 Modified: doc/trunk/design/syn/S02.pod doc/trunk/design/syn/S09.pod Log: * S02: Re-introduce comprehension, this time not context-specific, under the list() syntactic expression: # list() comprehension that evaluates to (2,3,5) 1 < list(1,1,2,3,5,8) < 8 * Also bump S09's version. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podSat Sep 30 20:16:38 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 10 Aug 2004 - Last Modified: 26 Sept 2006 + Last Modified: 1 Oct 2006 Number: 2 - Version: 73 + Version: 74 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -2148,6 +2148,32 @@ =item * +When evaluating chained operators, if a C occurs anywhere in that +chain, the chain will be transformed first into a C. That is, + +for 0 <= list(@x) < all(@y) {...} + +becomes + +for @x.grep:{ 0 <= $_ < all(@y) } {...} + +Because of this, the original ordering C<@x> is guaranteed to be +preserved in the returned list, and duplicate elements in C<@x> are +preserved as well. In particular, + +@result = list(@x) ~~ {...}; + +is equivalent to + +@result = @x.grep:{...}; + +However, this I is strictly a syntactic transformation, +so a list computed any other way will not triger the rewrite: + +@result = (@x = list(@y)) ~~ {...}; # not a comprehension + +=item * + The C<|> prefix operator may be used to force "capture" context on its argument and I defeat any scalar argument checking imposed by subroutine signature declarations. Any resulting list arguments are Modified: doc/trunk/design/syn/S09.pod == --- doc/trunk/design/syn/S09.pod(original) +++ doc/trunk/design/syn/S09.podSat Sep 30 20:16:38 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 13 Sep 2004 - Last Modified: 13 Sept 2006 + Last Modified: 1 Oct 2006 Number: 9 - Version: 14 + Version: 15 =head1 Overview
[svn:perl6-synopsis] r12561 - doc/trunk/design/syn
Author: audreyt Date: Mon Oct 2 07:45:13 2006 New Revision: 12561 Modified: doc/trunk/design/syn/S06.pod Log: * S06: Excise the word "Multimethod" in places where it also referred to multisubs. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podMon Oct 2 07:45:13 2006 @@ -13,9 +13,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 21 Mar 2003 - Last Modified: 25 Sept 2006 + Last Modified: 2 Oct 2006 Number: 6 - Version: 58 + Version: 59 This document summarizes Apocalypse 6, which covers subroutines and the @@ -52,7 +52,7 @@ =head1 Routine modifiers -B (keyword: C) are routines that can have multiple +B (keyword: C) are routines that can have multiple variants that share the same name, selected by arity, types, or some other constraints. @@ -1978,8 +1978,8 @@ =head2 The C function As mentioned above, a C call causes the innermost -surrounding subroutine, method, rule, token, regex (as a keyword), -macro, or multimethod to return. Only declarations with an explicit +surrounding subroutine, method, rule, token, regex (as a keyword) +or macro to return. Only declarations with an explicit keyword such as "sub" may be returned from. You may not return from a quotelike operator such as C. @@ -2212,7 +2212,7 @@ This special form should generally be restricted to named parameters. -To curry a particular multimethod it may be necessary to specify the type +To curry a particular multi variant, it may be necessary to specify the type for one or more of its parameters: &woof ::= &bark:(Dog).assuming :pitch;
[svn:perl6-synopsis] r12675 - doc/trunk/design/syn
Author: audreyt Date: Wed Oct 4 21:16:26 2006 New Revision: 12675 Modified: doc/trunk/design/syn/S12.pod Log: * S12: Remove the troublesome single-arg-function-become-method rule: sub foo (*$x) { $x } foo(want); # Always in list context, never evaluated as "want.foo" As an alternative solution to the "close $fh" problem, specify that class IO has a "method close () is export" that manufactures a multi sub-into-method dispatcher. The export-method semantics needs more detailed treatment in the spec, but it's important to note that "somesub $x" and "$x.somesub" are no longer interchangeable now. Modified: doc/trunk/design/syn/S12.pod == --- doc/trunk/design/syn/S12.pod(original) +++ doc/trunk/design/syn/S12.podWed Oct 4 21:16:26 2006 @@ -14,7 +14,7 @@ Date: 27 Oct 2004 Last Modified: 20 Sept 2006 Number: 12 - Version: 27 + Version: 28 =head1 Overview @@ -196,18 +196,24 @@ Indirect object notation now requires a colon after the invocant if there are any arguments. If there are no arguments and you omit the colon, the notation is parsed either as a named unary operator or a -list operator with one argument. In any case, all of these come out -to the same thing: +list operator with one argument. + +These two are considered method calls, which will fall back to a +subroutine call if the method was not found: $handle.close -close($handle) close $handle: -close $handle -To explicitly reject method call and only consider subs, put a -trailing comma after the single positional argument: +To reject method call and only consider subs, simply omit the colon +from the invocation line: -close($handle,) +close($handle) +close $handle + +However, here the built-in B class defines C, +which puts a C in scope by default. Thus if the +C<$handle> evaluates to an IO object, then the two subroutine calls above +are still translated into method calls. Dot notation can omit the invocant if it's in C<$_>:
[svn:perl6-synopsis] r13358 - doc/trunk/design/syn
Author: audreyt Date: Tue Oct 31 13:52:03 2006 New Revision: 13358 Modified: doc/trunk/design/syn/S06.pod Log: * S06: Fix Hash example typo spotted by cognominal++ Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podTue Oct 31 13:52:03 2006 @@ -13,9 +13,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 21 Mar 2003 - Last Modified: 16 Oct 2006 + Last Modified: 31 Oct 2006 Number: 6 - Version: 59 + Version: 60 This document summarizes Apocalypse 6, which covers subroutines and the @@ -386,7 +386,7 @@ Likewise, if you wish to pass a hash and have its entries treated as named arguments, you must dereference it with a C<|>: -%pairs = {:when :what}; +%pairs = (:when, :what); doit %pairs,1,2,3; # always a positional arg doit |%pairs,1,2,3; # always named args doit |%(get_pair()),1,2,3; # always a named arg
[svn:perl6-synopsis] r13366 - doc/trunk/design/syn
Author: audreyt Date: Wed Nov 1 07:51:52 2006 New Revision: 13366 Modified: doc/trunk/design/syn/S01.pod doc/trunk/design/syn/S11.pod Log: * S01 and S11: Per fglock++'s suggestion, add the "use v5;" compatibility form, which can occur only at the beginning of a lexical block: use v6-alpha; # ...some Perl 6 code... { use v5; # ...some Perl 5 code... { use v6-alpha; # ...more Perl 6 code... } } Modified: doc/trunk/design/syn/S01.pod == --- doc/trunk/design/syn/S01.pod(original) +++ doc/trunk/design/syn/S01.podWed Nov 1 07:51:52 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 10 Aug 2004 - Last Modified: 14 Sept 2006 + Last Modified: 1 Nob 2006 Number: 1 - Version: 4 + Version: 5 This document originally summarized Apocalypse 1, which covers the initial design concept. That original summary may be found below @@ -113,6 +113,23 @@ =item * +Migration in the other direction is also important. In Perl 6 +mode, one can drop back to Perl 5 mode with C at the +beginning of a lexical block. Such blocks may be nested: + +use v6-alpha; +# ...some Perl 6 code... +{ +use v5; +# ...some Perl 5 code... +{ +use v6-alpha; +# ...more Perl 6 code... +} +} + +=item * + Scaling is one of those areas where Perl needs to be multiparadigmatic and context sensitive. Perl 5 code is not strict by default, while Perl 6 code is. But it should be easy to relax with C<-e> or Modified: doc/trunk/design/syn/S11.pod == --- doc/trunk/design/syn/S11.pod(original) +++ doc/trunk/design/syn/S11.podWed Nov 1 07:51:52 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 27 Oct 2004 - Last Modified: 6 Jul 2006 + Last Modified: 1 Nov 2006 Number: 11 - Version: 14 + Version: 15 =head1 Overview @@ -341,6 +341,21 @@ a bare literal in a void context I to have produced a warning. (Invoking perl with C<-e6> has the same effect.) +In the other direction, to inline Perl 5 code inside a Perl 6 program, put +C at the beginning of a lexical block. Such blocks can nest arbitrarily +deeply to switch between Perl versions: + +use v6-alpha; +# ...some Perl 6 code... +{ +use v5; +# ...some Perl 5 code... +{ +use v6-alpha; +# ...more Perl 6 code... +} +} + It's not necessary to force Perl 6 if the interpreter or command specified already implies it, such as use of a "C<#!/usr/bin/perl6>" shebang line. Nor is it necessary to force Perl 6 in any file that
[svn:perl6-synopsis] r13377 - doc/trunk/design/syn
Author: audreyt Date: Thu Nov 2 03:00:10 2006 New Revision: 13377 Modified: doc/trunk/design/syn/S03.pod doc/trunk/design/syn/S06.pod Log: * S03: Missing semicolon. * S06: Missing comma. (spotted by cognominal++.) Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podThu Nov 2 03:00:10 2006 @@ -740,7 +740,7 @@ base operator. This means that you must parenthesize your comma lists for most operators. For example: - -« (1,2,3)# (-1, -2, -3) + -« (1,2,3); # (-1, -2, -3) (1,1,2,3,5) »+« (1,2,3,5,8); # (2,3,5,8,13) A unary hyper operator (either prefix or postfix) has only one Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podThu Nov 2 03:00:10 2006 @@ -715,7 +715,7 @@ takes a snapshot of what's left of the Capture at that point and then continues binding as if the Capture parameter weren't there: -sub compare (|$args Num $x, Num $y --> Bool) { ... } +sub compare (|$args, Num $x, Num $y --> Bool) { ... } =head2 Flattening argument lists
[svn:perl6-synopsis] r13379 - doc/trunk/design/syn
Author: audreyt Date: Thu Nov 2 03:23:56 2006 New Revision: 13379 Modified: doc/trunk/design/syn/S03.pod Log: * S03: Explicitly mention .=meth in the term level. * Also explicitly mention that the implicit topic for .meth and .=meth is $_. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podThu Nov 2 03:23:56 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 8 Mar 2004 - Last Modified: 30 Oct 2006 + Last Modified: 2 Nov 2006 Number: 3 - Version: 73 + Version: 74 =head1 Changes to Perl 5 operators @@ -1645,7 +1645,8 @@ terms 42 3.14 "eek" qq["foo"] [1,2,3] {...} \(@a,$b,%c) $x @y %z /abc/ MyType @@multidim $^a (1+2) a(1) :by(2) :!verbose :(Dog $self:) - .meth with implicit invocant + .meth with implicit invocant $_ + .=meth with implicit invocant $_ listops leftward method postfix .meth .+ .? .* .() .[] .{} .<> .«» .:: .= .^ autoincrement ++ --
[svn:perl6-synopsis] r13481 - doc/trunk/design/syn
Author: audreyt Date: Mon Nov 27 17:00:51 2006 New Revision: 13481 Modified: doc/trunk/design/syn/S06.pod Log: * S06: Trivial change from ?? :: to ?? !! Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podMon Nov 27 17:00:51 2006 @@ -2168,7 +2168,7 @@ my $anonfactorial = -> Int $n { $n < 2 ?? 1 - :: $n * &?BLOCK($n-1) + !! $n * &?BLOCK($n-1) }; C<&?BLOCK.label> contains the label of the current block, if any.
[svn:perl6-synopsis] r14309 - doc/trunk/design/syn
Author: audreyt Date: Mon Mar 5 08:20:56 2007 New Revision: 14309 Modified: doc/trunk/design/syn/S05.pod Log: * S05: Minor fixup for this sentence no verb. Modified: doc/trunk/design/syn/S05.pod == --- doc/trunk/design/syn/S05.pod(original) +++ doc/trunk/design/syn/S05.podMon Mar 5 08:20:56 2007 @@ -1698,7 +1698,7 @@ be possible to know when to fire off the assertions without backchecks.) Ordinary quantifiers and characters classes do not terminate a token pattern. -Zero-width assertions such as word boundaries also okay. +Zero-width assertions such as word boundaries are also okay. Oddly enough, the C keyword specifically does not determine the scope of a token, except insofar as a token pattern usually
[svn:perl6-synopsis] r14310 - doc/trunk/design/syn
Author: audreyt Date: Mon Mar 5 08:27:24 2007 New Revision: 14310 Modified: doc/trunk/design/syn/S12.pod Log: * S12: Clarify that VAR(1) and VAR(@foo) are simply no-ops; i.e., it applies to thiings other than Scalars, too. Also fixed the postfix macro name and nomenclature around .VAR. Modified: doc/trunk/design/syn/S12.pod == --- doc/trunk/design/syn/S12.pod(original) +++ doc/trunk/design/syn/S12.podMon Mar 5 08:27:24 2007 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 27 Oct 2004 - Last Modified: 20 Feb 2007 + Last Modified: 6 Mar 2007 Number: 12 - Version: 42 + Version: 43 =head1 Overview @@ -332,18 +332,23 @@ @keys = %hash.keys; $sig = &sub.signature; -Use the C pseudo-function on a scalar variable to get at its +Use the prefix C macro on a scalar variable to get at its underlying C object: if VAR($scalar).readonly {...} -There's also a corresponding postfix: macro that can be used +C is a no-op on a non-scalar variables and values: + +VAR(1); # 1 +VAR(@x);# @x + +There's also a corresponding C<< postfix:<.VAR> >> macro that can be used as if it were a method: if $scalar.VAR.readonly {...} (But since it's a macro, C is not dispatched as a real method. -To dispatch to a real C<.VAR> method use the indirect C<$obj."VAR"> +To dispatch to a real C<.VAR> method, use the indirect C<$obj."VAR"> form.) You can also get at the container through the appropriate symbol table:
[svn:perl6-synopsis] r14314 - doc/trunk/design/syn
Author: audreyt Date: Wed Mar 7 09:10:48 2007 New Revision: 14314 Modified: doc/trunk/design/syn/S06.pod Log: * S06: Instead of introducing the conjectural concept of single-semicolon delimited multiple-longnames, delegate the discussion to S12 and present the non-controversial double-semicolon form as the example instead. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podWed Mar 7 09:10:48 2007 @@ -13,9 +13,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 21 Mar 2003 - Last Modified: 28 Feb 2007 + Last Modified: 8 Mar 2007 Number: 6 - Version: 73 + Version: 74 This document summarizes Apocalypse 6, which covers subroutines and the @@ -510,22 +510,24 @@ =head2 Longname parameters -Much like ordinary methods give preference to the invocant, -multimethods and multisubs can give preference to earlier parameters. -These are called I; see S12 for more about the semantics -of multiple dispatch. Syntactically, longnames are declared by -terminating the list of important parameters with a semicolon: - -multi sub handle_event ($window, $event; $mode) {...} -multi method set_name ($self: $name; $nick) {...} - -A double semicolon terminates the longest possible longname; parameters -after this are never considered for multiple dispatch (except of course -that they can still "veto" if their number or types mismatch). (Note, -the single semicolon form is still considered conjectural, though the -double semicolon is fairly certain.) +Routines marked with C can mark part of its parameters to +be considered in the multi dispatch. These are called I; +see S12 for more about the semantics of multiple dispatch. -If the parameter list for a C contains no semicolon to delimit +You can choose part of a C's parameters to be its longname, +by putting a double semicolon after the last one: + +multi sub handle_event ($window, $event;; $mode) {...} +multi method set_name ($self: $name;; $nick) {...} + +A parameter list may have at most one double semicolon; parameters +after it are never considered for multiple dispatch (except of course +that they can still "veto" if their number or types mismatch). + +[Conjecture: It might be possible for a routine to advertise multiple +long names, delimited by single semicolons. See S12 for details.] + +If the parameter list for a C contains no semicolons to delimit the list of important parameters, then all positional parameters are considered important. If it's a C or C, an additional implicit unnamed C invocant is added to the @@ -745,8 +747,8 @@ is required at least for its types, or the declaration would not know what signature to match against. -multi foo (|$args (Int; Bool?, *@, *%)) { reallyintfoo($args) } -multi foo (|$args (Str; Bool?, *@, *%)) { reallystrfoo($args) } +multi foo (|$args (Int, Bool?, *@, *%)) { reallyintfoo($args) } +multi foo (|$args (Str, Bool?, *@, *%)) { reallystrfoo($args) } =head2 Flattening argument lists
[svn:perl6-synopsis] r14326 - doc/trunk/design/syn
Author: audreyt Date: Sat Mar 10 08:07:16 2007 New Revision: 14326 Modified: doc/trunk/design/syn/S12.pod Log: * S12: Remove self-contractictory paragraph about indirect object notation -- because the colon is needed regardless of whether there are arguments after it -- and also clarify that a fallback to sub call is _always_ performed, not only for method calls with no arguments. Modified: doc/trunk/design/syn/S12.pod == --- doc/trunk/design/syn/S12.pod(original) +++ doc/trunk/design/syn/S12.podSat Mar 10 08:07:16 2007 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 27 Oct 2004 - Last Modified: 6 Mar 2007 + Last Modified: 11 Mar 2007 Number: 12 - Version: 43 + Version: 44 =head1 Overview @@ -193,13 +193,11 @@ $obj.doit(1,2,3) doit $obj: 1,2,3 -Indirect object notation now requires a colon after the invocant if -there are any arguments. If there are no arguments and you omit the -colon, the notation is parsed either as a named unary operator or a -list operator with one argument. +If the method was not found, it will fall back to a subroutine call +instead, with the invocant becoming the first positional argument. -These two are considered method calls, which will fall back to a -subroutine call if the method was not found: +Indirect object notation now requires a colon after the invocant, +even if there are no arguments after the colon: $handle.close close $handle:
[svn:perl6-synopsis] r14331 - doc/trunk/design/syn
Author: audreyt Date: Sun Mar 11 08:17:58 2007 New Revision: 14331 Modified: doc/trunk/design/syn/S12.pod Log: * S12: Pass-throught methods should capture the entire invocation, not only the positional part. Also remove the bogus "is context". Modified: doc/trunk/design/syn/S12.pod == --- doc/trunk/design/syn/S12.pod(original) +++ doc/trunk/design/syn/S12.podSun Mar 11 08:17:58 2007 @@ -14,7 +14,7 @@ Date: 27 Oct 2004 Last Modified: 11 Mar 2007 Number: 12 - Version: 44 + Version: 45 =head1 Overview @@ -1310,7 +1310,7 @@ Since the method name (but nothing else) is known at class construction time, the following C<.wag> method is autogenerated for you: -method wag ([EMAIL PROTECTED] is context(Lazy)) { $!tail.wag(|@args) } +method wag (|$args) { $!tail.wag(|$args) } You can specify multiple method names:
[svn:perl6-synopsis] r14333 - doc/trunk/design/syn
Author: audreyt Date: Sun Mar 11 10:46:36 2007 New Revision: 14333 Modified: doc/trunk/design/syn/S03.pod Log: * S03: Unify scope declarator initializers with signature parameter initializers, yay! These forms are now fine: constant $x = 123; constant ($x = 123); constant :($x = 123); And this is naturally forbidden: constant ($x) = 123; Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podSun Mar 11 10:46:36 2007 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 8 Mar 2004 - Last Modified: 8 Mar 2007 + Last Modified: 12 Mar 2007 Number: 3 - Version: 105 + Version: 106 =head1 Overview @@ -3162,14 +3162,22 @@ Variable declarators such as C now take a I as their argument. (The syntax of function signatures is described more fully in S06.) + The parentheses around the signature may be omitted for a simple declaration that declares a single variable, along with its -associated type and traits. Parentheses must always be used when -declaring multiple parameters: +associated type, traits and the initializer: -my $a; # okay -my ($b, $c);# okay -my $b, $c; # wrong: "Use of undeclared variable: $c" +constant $foo = 123;# okay: initializes $foo to 123 +constant ($foo = 123); # same thing +constant :($foo = 123); # same thing (full Signature form) +constant ($foo) = 123; # wrong: constants cannot be assigned to + +Parentheses must always be used when declaring multiple parameters: + +my $a; # okay +my ($b, $c);# okay +my ($b = 1, $c = 2);# okay - "my" intializers assign at runtime +my $b, $c; # wrong: "Use of undeclared variable: $c" Types occurring between the declarator and the signature are distributed into each variable:
[svn:perl6-synopsis] r14335 - doc/trunk/design/syn
Author: audreyt Date: Sun Mar 11 14:17:24 2007 New Revision: 14335 Modified: doc/trunk/design/syn/S06.pod Log: * S06: Add the "only" routine modifier. Also state explicitly that modifiers cannot apply on anonymous routines. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podSun Mar 11 14:17:24 2007 @@ -13,9 +13,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 21 Mar 2003 - Last Modified: 11 Mar 2007 + Last Modified: 12 Mar 2007 Number: 6 - Version: 76 + Version: 77 This document summarizes Apocalypse 6, which covers subroutines and the @@ -59,20 +59,29 @@ B (keyword: C) specify the commonalities (such as parameter names, fixity, and associativity) shared by all multis of that name in the scope of the C declaration. A C -also forces all routines of the same short name within the scope to -be considered C whether they are explicitly declared so or not. +also adds an implicit C to all routines of the same short +name within its scope, unless they have an explicit modifier. (This is particularly useful when adding to rule sets or when attempting to compose conflicting methods from roles.) +C (keyword: C) routines do not share its short name +with other routines. This is the default modifier for all routines, +unless a C of the same name was already in scope. + A modifier keyword may occur before the routine keyword in a named routine: +only sub foo {...} proto sub foo {...} multi sub foo {...} + +only method bar {...} proto method bar {...} multi method bar {...} If the routine keyword is omitted, it defaults to C. +Modifier keywords cannot apply to anonymous routines. + =head2 Named subroutines The general syntax for named subroutines is any of:
[svn:perl6-synopsis] r14336 - doc/trunk/design/syn
Author: audreyt Date: Sun Mar 11 14:27:26 2007 New Revision: 14336 Modified: doc/trunk/design/syn/S06.pod Log: * typo; gaal++ Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podSun Mar 11 14:27:26 2007 @@ -64,7 +64,7 @@ (This is particularly useful when adding to rule sets or when attempting to compose conflicting methods from roles.) -C (keyword: C) routines do not share its short name +C (keyword: C) routines do not share their short names with other routines. This is the default modifier for all routines, unless a C of the same name was already in scope.
[svn:perl6-synopsis] r14337 - doc/trunk/design/syn
Author: audreyt Date: Sun Mar 11 14:52:42 2007 New Revision: 14337 Modified: doc/trunk/design/syn/S03.pod Log: * S03: Allow infix-assignment forms in the simple-one-arg case of variable declaration: constant Dog $fido .= new; # okay: a constant Dog object constant Dog $fido = Dog.new; # same thing However, this is not a generalized relaxation of the Signature syntax: constant Dog $fido = $fido.new; # error: cannot refer to itself constant (Dog $fido .= new);# error: cannot use .= with parens Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podSun Mar 11 14:52:42 2007 @@ -14,7 +14,7 @@ Date: 8 Mar 2004 Last Modified: 12 Mar 2007 Number: 3 - Version: 106 + Version: 107 =head1 Overview @@ -3172,6 +3172,15 @@ constant :($foo = 123); # same thing (full Signature form) constant ($foo) = 123; # wrong: constants cannot be assigned to +When parentheses are omitted, you may use an infix assignment operator +instea dof C<=> as the initializer. In that case, the left hand side of +the infix operator will be the variable's prototype object: + +constant Dog $fido .= new; # okay: a constant Dog object +constant Dog $fido = Dog.new; # same thing +constant Dog $fido = $fido.new; # error: cannot refer to itself +constant (Dog $fido .= new);# error: cannot use .= with parens + Parentheses must always be used when declaring multiple parameters: my $a; # okay
[svn:perl6-synopsis] r14338 - doc/trunk/design/syn
Author: audreyt Date: Mon Mar 12 04:00:33 2007 New Revision: 14338 Modified: doc/trunk/design/syn/S06.pod Log: * formatting code consistency suggested by Daniel Hulme. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podMon Mar 12 04:00:33 2007 @@ -64,7 +64,7 @@ (This is particularly useful when adding to rule sets or when attempting to compose conflicting methods from roles.) -C (keyword: C) routines do not share their short names +B (keyword: C) routines do not share their short names with other routines. This is the default modifier for all routines, unless a C of the same name was already in scope.
[svn:perl6-synopsis] r14340 - doc/trunk/design/syn
Author: audreyt Date: Mon Mar 12 14:02:33 2007 New Revision: 14340 Modified: doc/trunk/design/syn/S02.pod Log: * S02: typo spotted by rhr++ Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podMon Mar 12 14:02:33 2007 @@ -2472,7 +2472,7 @@ line number range within the source file. The lexical routine itself is C<&?ROUTINE>; you can get its name with -C<&ROUTINE.name>. The current block is C<&?BLOCK>. If the block has any +C<&?ROUTINE.name>. The current block is C<&?BLOCK>. If the block has any labels, those shows up in C<&?BLOCK.labels>. Within the lexical scope of a statement with a label, the label is a pseudo-object representing the dynamic context of that statement. (If inside multiple dynamic
[svn:perl6-synopsis] r14342 - doc/trunk/design/syn
Author: audreyt Date: Mon Mar 12 14:20:51 2007 New Revision: 14342 Modified: doc/trunk/design/syn/S03.pod Log: * S06: Clarify that simple parenless form of declarators must support list-context assignment. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podMon Mar 12 14:20:51 2007 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 8 Mar 2004 - Last Modified: 12 Mar 2007 + Last Modified: 13 Mar 2007 Number: 3 - Version: 108 + Version: 109 =head1 Overview @@ -3183,18 +3183,23 @@ associated type, traits and the initializer: constant $foo = 123;# okay: initializes $foo to 123 -constant ($foo = 123); # same thing +constant ($foo = 123); # same thing (with explicit parens) constant :($foo = 123); # same thing (full Signature form) constant ($foo) = 123; # wrong: constants cannot be assigned to +List-context assignment is supported for simple declarations: + +constant @foo = 1,2,3; # okay: initializes @foo to (1,2,3) +constant (@foo = 1,2,3);# wrong: 2 and 3 are not variable names + When parentheses are omitted, you may use an infix assignment operator instea dof C<=> as the initializer. In that case, the left hand side of the infix operator will be the variable's prototype object: constant Dog $fido .= new; # okay: a constant Dog object constant Dog $fido = Dog.new; # same thing -constant Dog $fido = $fido.new; # error: cannot refer to itself -constant (Dog $fido .= new);# error: cannot use .= with parens +constant Dog $fido = $fido.new; # wrong: invalid self-reference +constant (Dog $fido .= new);# wrong: cannot use .= with parens Parentheses must always be used when declaring multiple parameters:
[svn:perl6-synopsis] r14344 - doc/trunk/design/syn
Author: audreyt Date: Tue Mar 13 03:43:31 2007 New Revision: 14344 Modified: doc/trunk/design/syn/S02.pod Log: * S02: More fixups to reflect that fact that the f($x) form is always &f($x) and never $x.f() now. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podTue Mar 13 03:43:31 2007 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 10 Aug 2004 - Last Modified: 12 Mar 2007 + Last Modified: 13 Mar 2007 Number: 2 - Version: 95 + Version: 96 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -2287,7 +2287,7 @@ =item * There are no barewords in Perl 6. An undeclared bare identifier will -always be taken to mean a subroutine or method name. (Class names +always be taken to mean a subroutine name. (Class names (and other type names) are predeclared, or prefixed with the C<::> type sigil when you're declaring a new one.) A consequence of this is that there's no longer any "C". Since the syntax @@ -2300,9 +2300,12 @@ foo; # provisional call if neither &foo nor ::foo is defined so far foo(); # provisional call if &foo is not defined so far +foo($x); # provisional call if &foo is not defined so far foo($x, $y); # provisional call if &foo is not defined so far + $x.foo; # not a provisional call; it's a method call on $x -foo($x); # not a provisional call; it's a method call on $x +foo $x:; # not a provisional call; it's a method call on $x +foo $x: $y; # not a provisional call; it's a method call on $x If a postdeclaration is not seen, the compile fails at C time. (You are still free to predeclare subroutines explicitly, of course.)
[svn:perl6-synopsis] r14392 - doc/trunk/design/syn
Author: audreyt Date: Thu May 17 00:29:36 2007 New Revision: 14392 Modified: doc/trunk/design/syn/S02.pod doc/trunk/design/syn/S04.pod doc/trunk/design/syn/S06.pod Log: * Fix thrice misspelling of &?BLOCK as $?BLOCK. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podThu May 17 00:29:36 2007 @@ -1674,7 +1674,7 @@ @?LABEL Which nested block labels am I in? All the nested C<@?> variables are ordered from the innermost to the -outermost, so C<@?BLOCK[0]> is always the same as C<$?BLOCK>. +outermost, so C<@?BLOCK[0]> is always the same as C<&?BLOCK>. Note that some of these things have parallels in the C<*> space at run time: Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podThu May 17 00:29:36 2007 @@ -724,7 +724,7 @@ is really just short for: -$?BLOCK.leave(1,2,3) +&?BLOCK.leave(1,2,3) To return from your immediate caller, you can say: Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podThu May 17 00:29:36 2007 @@ -1910,7 +1910,7 @@ and the method's arguments specify the return value. If the object is omitted (by use of the function or listop forms), the innermost block is exited. Otherwise you must use something like C -or C<$?BLOCK> or a contextual variable to specify the scope you +or C<&?BLOCK> or a contextual variable to specify the scope you want to exit. A label (such as a loop label) previously seen in the lexical scope also works as a kind of singleton context object: it names a statement that is serving both as an outer lexical scope
[svn:perl6-synopsis] r14532 - doc/trunk/design/syn
Author: audreyt Date: Wed Apr 2 08:56:38 2008 New Revision: 14532 Modified: doc/trunk/design/syn/S09.pod Log: * S09/"Parallelized parameters and autothreading": @a[$i, $j] etc in examples should read @a[$i; $j] instead. Also, clarify that "do -> { ... }" is intentionally calling the block via the do-once loop syntax, because a pointy sub at that point wouldn't trigger the statement-level-bare-block-autocall rule. Reported by: John M. Dlugosz Modified: doc/trunk/design/syn/S09.pod == --- doc/trunk/design/syn/S09.pod(original) +++ doc/trunk/design/syn/S09.podWed Apr 2 08:56:38 2008 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 13 Sep 2004 - Last Modified: 17 Mar 2008 + Last Modified: 2 Apr 2008 Number: 9 - Version: 24 + Version: 25 =head1 Overview @@ -1044,28 +1044,34 @@ In the abstract (and often in the concrete), this puts an implicit loop around the block of the closure that visits all the possible subscript values for that dimension (unless the parameter is actually -supplied to the closure, in which case that is what is used as the -slice subscript). This implicit loop is assumed to be parallelizable. +supplied to the closure, in which case the supplied value is used as +the slice subscript instead). + +This implicit loop is assumed to be parallelizable. So to write a typical tensor multiplication: Cijkl = Aij * Bkl -you can just write this: +you can simply call a closure with no arguments, allowing the C +pragma to fill in the defaults: use autoindex; -do { @c[$^i, $^j, $^k, $^l] = @a[$^i, $^j] * @b[$^k, $^l] }; - -or equivalently: +-> $i, $j, $k, $l { @c[$i; $j; $k; $l] = @a[$i; $j] * @b[$k; $l] }(); --> $i, $j, $k, $l { @c[$i, $j, $k, $l] = @a[$i, $j] * @b[$k, $l] }(); - -or even: +or you can use the C syntax (see L) to +call that closure, which also implicitly iterates: +use autoindex; do -> $i, $j, $k, $l { -@c[$i, $j, $k, $l] = @a[$i, $j] * @b[$k, $l] +@c[$i; $j; $k; $l] = @a[$i; $j] * @b[$k; $l] } +or even use placeholder variables instead of a parameter list: + +use autoindex; +do { @c[$^i; $^j; $^k; $^l] = @a[$^i; $^j] * @b[$^k; $^l] }; + That's almost pretty. It is erroneous for an unbound parameter to match multiple existing array
[svn:perl6-synopsis] r14533 - doc/trunk/design/syn
Author: audreyt Date: Wed Apr 2 09:13:06 2008 New Revision: 14533 Modified: doc/trunk/design/syn/S09.pod Log: * S09/Autovivification: Change the wording "assignment implicitly binds a copy" to "assignment is treated the same way as binding to a copy container", because assignment and binding are two orthogonal concepts. Reported by: John M. Dlugosz Modified: doc/trunk/design/syn/S09.pod == --- doc/trunk/design/syn/S09.pod(original) +++ doc/trunk/design/syn/S09.podWed Apr 2 09:13:06 2008 @@ -14,7 +14,7 @@ Date: 13 Sep 2004 Last Modified: 2 Apr 2008 Number: 9 - Version: 25 + Version: 26 =head1 Overview @@ -1168,10 +1168,14 @@ Autovivification will only happen if the vivifiable path is bound to a read-write container. Value extraction (that is, binding to a readonly -or copy container) does not autovivify. (Note that assignment implicitly -binds a copy, so it does not autovivify its right side.) Any mention of -an expression within a C delays the autovivification decision -to binding time. (Binding to a "ref" parameter also defers the decision.) +or copy container) does not autovivify. + +Note that assignment is treated the same way as binding to a copy container, +so it does not autovivify its right side either. + +Any mention of an expression within a C delays the autovivification +decision to binding time. (Binding to a "ref" parameter also defers the +decision.) This is as opposed to Perl 5, where autovivification could happen unintentionally, even when the code looks like a non-destructive test:
[svn:perl6-synopsis] r14536 - doc/trunk/design/syn
Author: audreyt Date: Wed Apr 2 10:22:01 2008 New Revision: 14536 Modified: doc/trunk/design/syn/S04.pod Log: * S04: Create a new section, "Statement-level bare blocks" since its content doesn't really belong in the "do-once loop" section. * S04: Also, clarify that statement-level blocks with placeholder variables should trigger an error, unless prefixed with "do" or postfixed with a modifier. Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podWed Apr 2 10:22:01 2008 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 19 Aug 2004 - Last Modified: 8 Feb 2008 + Last Modified: 2 Apr 2008 Number: 4 - Version: 64 + Version: 65 This document summarizes Apocalypse 4, which covers the block and statement syntax of Perl. @@ -533,15 +533,6 @@ useful for the do-once block, since it is offically a loop and can take therefore loop control statements. -Although a bare block is no longer a do-once loop, it still executes -immediately as in Perl 5, as if it were immediately dereferenced with -a C<.()> postfix, so within such a block C refers to the -scope surrounding the block. If you wish to return a closure from a -function, you must use an explicit prefix such as C or C -or C<< -> >>. (Use of a placeholder parameter is deemed insufficiently -explicit because it's not out front where it can be seen. You can, of -course, use a placeholder parameter if you also use C.) - Another consequence of this is that any block just inside a left parenthesis is immediately called like a bare block, so a multidimensional list comprehension may be written using a block with @@ -553,6 +544,32 @@ @names = ({ "$^name.$^num" } for 'a'..'zzz' X 1..100); +=head2 Statement-level bare blocks + +Although a bare block occuring as a single statement is no longer +a do-once loop, it still executes immediately as in Perl 5, as if it +were immediately dereferenced with a C<.()> postfix, so within such a +block C refers to the scope surrounding the block. + +If you wish to return a closure from a function, you must use an +explicit prefix such as C or C or C<< -> >>. + +Use of a placeholder parameter in statement-level blocks triggers a +syntax error, because the parameter is not out front where it can be +seen. However, it's not an error when prefixed by a C, or when +followed by a statement modifier: + +# Syntax error: Statement-level placeholder block +{ say $^x }; + +# Not an syntax error, though $x doesn't get the argument it wants +do { say $^x }; + +# Not an error: Equivalent to "for 1..10 -> $x { say $x }" +{ say $^x } for 1..10; + +# Not an error: Equivalent to "if foo() -> $x { say $x }" +{ say $^x } if foo(); =head2 The gather statement
[svn:perl6-synopsis] r14538 - doc/trunk/design/syn
Author: audreyt Date: Wed Apr 2 12:04:08 2008 New Revision: 14538 Modified: doc/trunk/design/syn/S03.pod Log: * S03/"Hash composer": Update the definition to agree with S04/"hash composer", allowing empty hashes as well as lists beginning with hashes. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podWed Apr 2 12:04:08 2008 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 8 Mar 2004 - Last Modified: 31 Mar 2008 + Last Modified: 2 Apr 2008 Number: 3 - Version: 134 + Version: 135 =head1 Overview @@ -146,10 +146,11 @@ Hash composer +{ } { a => 42 } -Inside must be a list of pairs, otherwise you must use C -or C<%()> instead. +Inside must be either empty, or a single list starting with a pair or a hash, +otherwise you must use C or C<%()> instead. =item *
[svn:perl6-synopsis] r14572 - doc/trunk/design/syn
Author: audreyt Date: Tue Aug 5 02:43:49 2008 New Revision: 14572 Modified: doc/trunk/design/syn/S12.pod Log: * Typo spotted by John M. Dlugosz++: method close is export () { ... } # Wrong method close () is export { ... } # Right Modified: doc/trunk/design/syn/S12.pod == --- doc/trunk/design/syn/S12.pod(original) +++ doc/trunk/design/syn/S12.podTue Aug 5 02:43:49 2008 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 27 Oct 2004 - Last Modified: 10 Jul 2008 + Last Modified: 5 Aug 2008 Number: 12 - Version: 61 + Version: 62 =head1 Overview @@ -222,7 +222,7 @@ close($handle); close $handle; -However, here the built-in B class defines C, +However, here the built-in B class defines C, which puts a C in scope by default. Thus if the C<$handle> evaluates to an IO object, then the two subroutine calls above are still translated into method calls.
[svn:perl6-synopsis] r14571 - doc/trunk/design/syn
Author: audreyt Date: Tue Aug 5 02:38:33 2008 New Revision: 14571 Modified: doc/trunk/design/syn/S02.pod Log: * S02: A few more C<...> an C<<...>> blocks, Contributed by John M. Dlugosz++. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podTue Aug 5 02:38:33 2008 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 10 Aug 2004 - Last Modified: 25 Jul 2008 + Last Modified: 5 Aug 2008 Number: 2 - Version: 133 + Version: 134 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -1415,7 +1415,7 @@ There is a need to distinguish list assignment from list binding. 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 +names to C and C objects without copying, in the same way as subroutine arguments are bound to formal parameters. See S06 for more about binding. @@ -1544,7 +1544,7 @@ =item * -In numeric context (i.e. when cast into C or C), a Hash object +In numeric context (i.e. when cast into C or C), a C object becomes the number of pairs contained in the hash. In a boolean context, a Hash object is true if there are any pairs in the hash. In either case, any intrinsic iterator would be reset. (If hashes do carry an intrinsic @@ -1807,7 +1807,7 @@ it starts in the current dynamic scope and from there scans outward through all dynamic scopes until it finds a contextual variable of that name in that context's lexical scope. -(Use of C<$+FOO> is equivalent to CONTEXT::<$FOO> or $CONTEXT::FOO.) +(Use of C<$+FOO> is equivalent to C<< CONTEXT::<$FOO> >> or C<< $CONTEXT::FOO >>.) If after scanning all the lexical scopes of each dynamic scope, there is no variable of that name, it looks in the C<*> package. If there is no variable in the C<*> package and the variable is @@ -1921,7 +1921,7 @@ C<$?FILE> and C<$?LINE> are your current file and line number, for instance. C is not a shortcut for a package name like C<*> is. Instead of C<$?OUTER::SUB> you probably want to write C<< OUTER::<$?SUB> >>. -Within code that is being run during the compile, such as BEGIN blocks, or +Within code that is being run during the compile, such as C blocks, or macro bodies, or constant initializers, the compiler variables must be referred to as (for instance) C<< COMPILING::<$?LINE> >> if the bare C<$?LINE> would be taken to be the value during the compilation of the currently running