[svn:perl6-synopsis] r7784 - doc/trunk/design/syn
Author: autrijus Date: Wed Feb 22 11:01:51 2006 New Revision: 7784 Modified: doc/trunk/design/syn/S12.pod Log: * S12: replace the inaccurate use "eigenclass" with "metaclass" * Also specify "$.foo" and "$.foo(...)" forms as contextful shorthands of method calls on self. Modified: doc/trunk/design/syn/S12.pod == --- doc/trunk/design/syn/S12.pod(original) +++ doc/trunk/design/syn/S12.podWed Feb 22 11:01:51 2006 @@ -303,16 +303,16 @@ pass it a prototype object such as "Dog" object is, as long as the method body doesn't try to access any information that is undefined in the current instance. -Alternately, you can associate a class method with the current eigenclass instance, +Alternately, you can associate a class method with the current metaclass instance, which as a singleton object knows your package, and can function as a more traditional "class" method: our $count; method ^count { return $count } -Such an "eigenmethod" is delegated to C<.meta> just as method like .does are, -so it's possible to call this as C or C<$dog.count>. However, -best practice is probably to call such a class method as C +Such an I is always delegated to C<.meta> just as method like +C<.does> are, so it's possible to call this as C or C<$dog.count>. +However, best practice is probably to call such a class method as C or C<$dog.^count> to make it clear that it's in its own namespace separate from ordinary methods, and so that your class method cannot be accidentally overridden by an ordinary method in a subclass--presuming you don't want to @@ -377,12 +377,25 @@ directly to the attribute values. Outsi only access to attributes is through the accessors since an object has to be specified. The dot form of attribute variables may be used in derived classes because the dot form always implies a virtual accessor -call. Every "dot" declaration also declares a corresponding private -"exclamation" storage location, and the exclamation form may be used +call. Every I declaration also declares a corresponding private +I storage location, and the exclamation form may be used only in the actual class, not in derived classes. Reference to the internal storage location via C<$!foo> should generally be restricted to submethods. Ordinary methods should stick to the C<$.foo> form. +Because C<$.foo>, C<@.foo>, C<%.foo>, C<&.foo> are just shorthands of +C with different contexts, the class does not need to declare C as a property -- a C declaration can work just as well. + +The dot form can take an argument list as well. These are all equivalent: + +self.foo(1,2,3);# a regular method call +self.foo.(1,2,3); # ditto +$.foo(1,2,3); # calls self.foo under $ context +$.foo.(1,2,3); # ditto +@.foo(1,2,3); # calls self.foo under @ context +@.foo.(1,2,3); # ditto + Pseudo-assignment to an attribute declaration specifies the default value. The value on the right is evaluated at class composition time, that is, while the class is being compiled and the class
[svn:perl6-synopsis] r7812 - doc/trunk/design/syn
Author: autrijus Date: Thu Feb 23 13:25:31 2006 New Revision: 7812 Modified: doc/trunk/design/syn/S11.pod Log: * S11: Inner modules can now decalare "is export" as well; exports are now collected with the inner ::EXPORT module, with tagsets as inner modules within it; "use" can now re-export the symbols with :EXPORT. Modified: doc/trunk/design/syn/S11.pod == --- doc/trunk/design/syn/S11.pod(original) +++ doc/trunk/design/syn/S11.podThu Feb 23 13:25:31 2006 @@ -77,13 +77,34 @@ Module traits are set using C: Exportation is now done by trait declaration on the exportable item: - # Tagset... +module Foo;# Tagset... sub foo is export(:DEFAULT) {...} # :DEFAULT, :ALL sub bar is export(:DEFAULT :others) {...} # :DEFAULT, :ALL, :others sub baz is export(:MANDATORY) {...} # (always exported) sub bop is export {...} # :ALL sub qux is export(:others) {...} # :ALL, :others +Declarations marked as C are bound into the C inner +modules, with their tagsets as inner module names within it. For example, +the C above will bind as C<&Foo::EXPORT::DEFAULT::bar>, +C<&Foo::EXPORT::ALL::bar>, and C<&Foo::EXPORT::others::bar>. + +Inner modules automatically add their export list to modules in its +all outer scope: + +module Foo { +sub foo is export {...} +module Bar { +sub bar is export {...} +module Baz { +sub baz is export {...} +} +} +} + +The C module will export C<&foo>, C<&bar> and C<&baz> by default; +calling C will import C<&bar> and C<&baz> at runtime. + =head1 Compile-time Importation Importing via C binds into the current lexical scope by default @@ -102,6 +123,12 @@ That's pretty much equivalent to: our @horse ::= @Sense::horse; $*warming ::= $Sense::warming; +It is also possible to re-export the imported symbols: + +use Sense :EXPORT; # import and re-export the defaults +use Sense :EXPORT; # import "common" and re-export it +use Sense :EXPORT<@horse>; # import "common" but exports "@horse" + In the absence of a specific scoping specified by the caller, the module may also specify a different scoping default by use of C<:MY> or C<:OUR> tags as arguments to C. (Of course, mixing incompatible scoping
[svn:perl6-synopsis] r7814 - doc/trunk/design/syn
Author: autrijus Date: Thu Feb 23 13:35:36 2006 New Revision: 7814 Modified: doc/trunk/design/syn/S11.pod Log: * S11 typo fix and version bump. Modified: doc/trunk/design/syn/S11.pod == --- doc/trunk/design/syn/S11.pod(original) +++ doc/trunk/design/syn/S11.podThu Feb 23 13:35:36 2006 @@ -14,7 +14,7 @@ Larry Wall <[EMAIL PROTECTED]> Date: 27 Oct 2004 Last Modified: 22 Feb 2006 Number: 11 - Version: 7 + Version: 8 =head1 Overview @@ -89,8 +89,8 @@ modules, with their tagsets as inner mod the C above will bind as C<&Foo::EXPORT::DEFAULT::bar>, C<&Foo::EXPORT::ALL::bar>, and C<&Foo::EXPORT::others::bar>. -Inner modules automatically add their export list to modules in its -all outer scope: +Inner modules automatically add their export list to modules in all their +outer scopes: module Foo { sub foo is export {...}
[svn:perl6-synopsis] r7831 - doc/trunk/design/syn
Author: autrijus Date: Thu Feb 23 17:02:39 2006 New Revision: 7831 Modified: doc/trunk/design/syn/S11.pod doc/trunk/design/syn/S12.pod Log: * S11: fix another typo. Typo`R`us. * S12: remove the remaining "eigenclass" misnomer when it means "metaclass". Modified: doc/trunk/design/syn/S11.pod == --- doc/trunk/design/syn/S11.pod(original) +++ doc/trunk/design/syn/S11.podThu Feb 23 17:02:39 2006 @@ -295,7 +295,7 @@ version number or other literal: 6; "Coolness, dude!"; -it runs Perl 6 in "lax" mode, without strictures or warnings, since obvously +it runs Perl 6 in "lax" mode, without strictures or warnings, since obviously a bare literal in a void context I to have produced a warning. (Invoking perl with C<-e6> has the same effect.) Modified: doc/trunk/design/syn/S12.pod == --- doc/trunk/design/syn/S12.pod(original) +++ doc/trunk/design/syn/S12.podThu Feb 23 17:02:39 2006 @@ -134,7 +134,7 @@ metaclass chooses to dispatch the .defin The notation C<^Dog> is syntactic sugar for C, so C<^> can be considered the "class" sigil when you want to talk about the current -eigenclass instance. +metaclass instance. Classes are open and non-final by default, but may easily be closed or finalized not by themselves but by the entire application, provided
[svn:perl6-synopsis] r7839 - doc/trunk/design/syn
Author: autrijus Date: Fri Feb 24 05:49:02 2006 New Revision: 7839 Modified: doc/trunk/design/syn/S02.pod doc/trunk/design/syn/S04.pod doc/trunk/design/syn/S06.pod Log: * Textual cleanup of S2/4/6. No functional changes. - Change sentences like "Perl 6 will support" to "Perl 6 supports" - References to A* becomes S0*. - Make it clear that "::Foo.bar()" does not interpolate in strings. - The ".each" in S06 was actually a thinko for ".map". Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podFri Feb 24 05:49:02 2006 @@ -111,22 +111,23 @@ be trivial to declare them as a macro). =item * In support of OO encapsulation, there is a new fundamental datatype: -"opaque". External access to opaque objects is always through method +B. External access to opaque objects is always through method calls, even for attributes. =item * -Perl 6 will have an optional type system that helps you write safer +Perl 6 has an optional type system that helps you write safer code that performs better. The compiler is free to infer what type information it can from the types you supply, but will not complain about missing type information unless you ask it to. =item * -Perl 6 will support the notion of "properties" on various kinds of +Perl 6 supports the notion of B on various kinds of objects. Properties are like object attributes, except that they're managed by the individual object rather than by the object's class. -According to A12, properties are actually implemented by a + +According to S12, properties are actually implemented by a kind of mixin mechanism, and such mixins are accomplished by the generation of an individual anonymous class for the object (unless an identical anonymous class already exists and can safely be shared). @@ -134,7 +135,7 @@ an identical anonymous class already exi =item * Properties applied to compile-time objects such as variables and -classes are also called "traits". Traits are not expected to change +classes are also called B. Traits are not expected to change at run time. Changing run-time properties should be done via mixin instead, so that the compiler can optimize based on declared traits. @@ -150,7 +151,7 @@ than in Perl 5. A variable's type is an interface contract indicating what sorts of values the variable may contain. More precisely, it's a promise that the object or objects contained in the variable are capable of -responding to the methods of the indicated "role". See A12 for more +responding to the methods of the indicated "role". See S12 for more about roles. A variable object may itself be bound to a container type that specifies how the container works without necessarily specifying what kinds of things it contains. @@ -158,15 +159,16 @@ specifying what kinds of things it conta =item * You'll be able to ask for the length of an array, but it won't be -called that, because "length" does not specify units. So -C<.elems> is the number of array elements. (You can also +called that, because C does not specify units. So +C<.elems> is the number of array elements. You can also ask for the length of an array in bytes or codepoints or graphemes. -Same for strings. There is no C<.length> on strings either.) +The same methods apply to strings as well: there is no C<.length> on +strings either. =item * C by itself does not automatically call a C constructor. -The actual constructor syntax turns out to be C, +The actual constructor syntax turns out to be C, making use of the C<.=> mutator method-call syntax. =item * @@ -194,7 +196,7 @@ than the native type can speed it up.) =item * -All Object types support the "undefined" role, and may contain an +All Object types support the C role, and may contain an alternate set of attributes when undefined, such as the unthrown exception explaining why the value is undefined. Non-object types are not required to support undefinedness, but it is an error to @@ -209,7 +211,7 @@ used as a "kind" when the context requir =item * -Perl 6 will intrinsically support big integers and rationals through +Perl 6 intrinsically supports big integers and rationals through its system of type declarations. C automatically supports promotion to arbitrary precision. C supports arbitrary precision rational arithmetic. Value types like C and C imply @@ -227,10 +229,10 @@ on overflow. =item * -A C is a Unicode string object of some sort. A C is -a stringish view of an array of integers, and has no Unicode or -character properties without explicit conversion to some kind of C. -Typically it's an array of bytes
[svn:perl6-synopsis] r7849 - doc/trunk/design/syn
Author: autrijus Date: Fri Feb 24 10:58:18 2006 New Revision: 7849 Modified: doc/trunk/design/syn/S06.pod doc/trunk/design/syn/S10.pod doc/trunk/design/syn/S13.pod Log: * more A*->S* changes. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podFri Feb 24 10:58:18 2006 @@ -1443,7 +1443,7 @@ The C (I)> syntax spec return 0 but true; } -Properties are predeclared as roles and implemented as mixins--see A12. +Properties are predeclared as roles and implemented as mixins--see S12. =head2 Subroutine traits Modified: doc/trunk/design/syn/S10.pod == --- doc/trunk/design/syn/S10.pod(original) +++ doc/trunk/design/syn/S10.podFri Feb 24 10:58:18 2006 @@ -119,7 +119,7 @@ These routines are expected to define th it, since the call is already "scheduled" from somewhere else. (The C is implicit, in other words. But you can hijack the call via the C builtin, in which case the autoloader -behaves just like a wrapper--see A6.) +behaves just like a wrapper--see S06.) In any case, there is no longer any magical C<$AUTOLOAD> variable. The name being declared or defined can be found in C<$_> Modified: doc/trunk/design/syn/S13.pod == --- doc/trunk/design/syn/S13.pod(original) +++ doc/trunk/design/syn/S13.podFri Feb 24 10:58:18 2006 @@ -39,7 +39,7 @@ any trickery involving swapping the argu type instead of the left one. And there's no longer any need to examine a special flag to see if the arguments were reversed. -For much more about multiple dispatch, see A12. +For much more about multiple dispatch, see S12. =head1 Syntax
[svn:perl6-synopsis] r7853 - doc/trunk/design/syn
Author: autrijus Date: Fri Feb 24 12:21:45 2006 New Revision: 7853 Modified: doc/trunk/design/syn/S04.pod Log: * S04: The "If a curly occurs by a line by itself, then it stands for end of statement" rule from A04 is brought foward and further generalized -- now it only has to be at the end of line. This allows: # semicolon optional after an end-of-line brace try { ... } another_expression; and forbids: # comma needed between two subs sub f { ... } sub g { ... } Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podFri Feb 24 12:21:45 2006 @@ -12,9 +12,9 @@ Larry Wall <[EMAIL PROTECTED]> Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 19 Aug 2004 - Last Modified: 31 Jan 2006 + Last Modified: 24 Feb 2006 Number: 4 - Version: 8 + Version: 9 This document summarizes Apocalypse 4, which covers the block and statement syntax of Perl. @@ -92,6 +92,33 @@ value will be restored only if the curre or hypotheticalize the value or the variable depending on whether you do assignment or binding. +=head1 Statement-ending blocks + +A line ending with a closing brace "C<}>", followed by nothing but +whitespace or comments, will terminates statement if an end of statement +can occur there. That is, these two statements are equivalent: + +my $x = sub { 3 } +my $x = sub { 3 }; + +End-of-statement cannot occur within a bracketed expression, so +this still works: + +my $x = [ +sub { 3 }, # this comma is not optional +sub { 3 } # the statement won't terminate here +]; + +Because subroutine declarations are expressions, not statements, +this is now invalid: + +sub f { 3 } sub g { 3 } # two terms occur in a row + +But these two are valid: + +sub f { 3 }; sub g { 3 }; +sub f { 3 }; sub g { 3 }# the trailing semicolon is optional + =head1 Conditional statements The C and C statements work almost exactly as they do in
[svn:perl6-synopsis] r7858 - doc/trunk/design/syn
Author: autrijus Date: Fri Feb 24 14:16:49 2006 New Revision: 7858 Modified: doc/trunk/design/syn/S09.pod Log: * S09: Autovivification no longer happens under rvalue context. Suggested and contributed by Yuval Kogman. Modified: doc/trunk/design/syn/S09.pod == --- doc/trunk/design/syn/S09.pod(original) +++ doc/trunk/design/syn/S09.podFri Feb 24 14:16:49 2006 @@ -672,3 +672,33 @@ a list of keys, the size of which is the number of declared dimensions of the hash. [XXX but this seems to imply another lookup to find the value. Perhaps the associated value can also be bundled in somehow.] + +=head1 Autovivification + +Autovivification will only happen if the vivifiable path is used as a +container, by binding, assigning, or taking a reference. On the other hand, +value extraction does not autovivify. + +This is as opposed to Perl 5, where autovivification could happen +unintentionally, even when the code looks like a non-destructive test: + +my %hash; +exists $hash{foo}{bar}; # creates $hash{foo} as an empty hash reference + +In Perl 6 these read-only operations are indeed non-destructive: + +my %hash; +exists $hash{foo}{bar}; # %hash is still empty + +But these ones I autovivify: + +my %hash; +my $val := $hash{foo}{bar}; + +my @array; +my $ref = \$array[0][0]; + +my %hash; +$hash{foo}{bar} = "foo"; # duh + +This rule applies to dereferencing arrays, hashes, and scalar references.
[svn:perl6-synopsis] r7859 - doc/trunk/design/syn
Author: autrijus Date: Fri Feb 24 15:05:03 2006 New Revision: 7859 Modified: doc/trunk/design/syn/S05.pod Log: * returning from within a rule sets the "result object", which can be accessed with the .() dereferencer. Modified: doc/trunk/design/syn/S05.pod == --- doc/trunk/design/syn/S05.pod(original) +++ doc/trunk/design/syn/S05.podFri Feb 24 15:05:03 2006 @@ -13,9 +13,9 @@ Maintainer: Patrick Michaud <[EMAIL PROTECTED]> Date: 24 Jun 2002 - Last Modified: 2 Feb 2006 + Last Modified: 24 Feb 2006 Number: 5 - Version: 9 + Version: 10 This document summarizes Apocalypse 5, which is about the new regex syntax. We now try to call them "rules" because they haven't been @@ -1063,7 +1063,8 @@ =item * -In string context it evaluates to the entire matched string: +In string context it evaluates to the stringified value of its +I, which is usually the entire matched string: print %hash{ "{$text ~~ //}" }; # or equivalently: @@ -1073,8 +1074,8 @@ =item * -In numeric context it evaluates to the numeric value of the entire matched -string: +In numeric context it evaluates to the numeric value of its +I, which is usually the entire matched string: $sum += /\d+/; # or equivalently: @@ -1082,8 +1083,20 @@ =item * -When used as an array, C<$/> pretends to be an array containing -C<$0>, C<$1>, etc. Hence +When used as a closure, a Match object evaluates to its underlying +result object. Usually this is just the entire match string, but +you can override that by calling C inside a rule: + +my $moose = m:{ + +{ return Moose.new( body => $.attach(:$) ) } +# match succeeds -- ignore the rest of the rule +}.(); + +=item * + +When used as an array, a Match object pretends to be an array of all +its positional captures. Hence ($key, $val) = m:w/ (\S+) => (\S+)/; @@ -1105,7 +1118,7 @@ =item * -When used as a hash, C<$/> pretends to be a hash of all the named +When used as a hash, a Match object pretends to be a hash of all its named captures. The keys do not include any sigils, so if you capture to variable C<< @ >> its real name is C<$/{'foo'}> or C<< $/ >>. However, you may still refer to it as C<< @ >> anywhere C<$/>
[svn:perl6-synopsis] r7867 - doc/trunk/design/syn
Author: autrijus Date: Sat Feb 25 01:59:19 2006 New Revision: 7867 Modified: doc/trunk/design/syn/S05.pod Log: * S05: Fix the <(...)> typo (was spelled <(...\>) and make the moose example slightly more idiomatic. Modified: doc/trunk/design/syn/S05.pod == --- doc/trunk/design/syn/S05.pod(original) +++ doc/trunk/design/syn/S05.podSat Feb 25 01:59:19 2006 @@ -1115,17 +1115,17 @@ my $moose = m:{ -{ return Moose.new( body => $.attach(:$) ) } +{ return Moose.new( body => $().attach($()) ) } # match succeeds -- ignore the rest of the rule }.(); C<$()> is a shorthand for C<$/.()> or C<$/()>. The result object -may contain any object, not just a string. +may be of any type, not just a string. You may also capture a subset of the match as the result object using the C<< <(...)> construct: -"foo123bar" ~~ / foo <( \d+ \> bar / +"foo123bar" ~~ / foo <( \d+ )> bar / say $();# says 123 In this case the result object is always a string when doing string
[svn:perl6-synopsis] r7874 - doc/trunk/design/syn
Author: autrijus Date: Sun Feb 26 01:32:17 2006 New Revision: 7874 Modified: doc/trunk/design/syn/S11.pod Log: * S11: Import from pseudo-packages like GLOBAL and CALLER. Modified: doc/trunk/design/syn/S11.pod == --- doc/trunk/design/syn/S11.pod(original) +++ doc/trunk/design/syn/S11.podSun Feb 26 01:32:17 2006 @@ -155,6 +155,21 @@ require Sense; Sense.import; # goes to the OUR scope by default, not MY +=head1 Importing from a pseudo-package + +You may also import symbols from the various pseudo-packages listed in S02. +They behave as if all their symbols are in the C<:ALL> export list: + +use GLOBAL <$IN $OUT $ERR>; +require CALLER <$x $y>; + +# Same as: +# my ($IN, $OUT, $ERR) ::= ($*IN, $*OUT, $*ERR) +# my ($x, $y) := ($CALLER::x, $CALLER::y) + +As pseudo-packages are always already preloaded, C and C will +never attempt to load, for example, C from an external source. + =head1 Versioning When at the top of a file you say something like
[svn:perl6-synopsis] r7875 - doc/trunk/design/syn
Author: autrijus Date: Sun Feb 26 01:35:45 2006 New Revision: 7875 Modified: doc/trunk/design/syn/S06.pod Log: * S06: Explicit importation in q:code// from the :COMPILING scope using the q:code(:COMPILING<$x>)// form. * Also point out we can easily bind symbols at macro-run time, thanks to pseudo-package import in S11: require COMPILING <$x $y $z>; Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podSun Feb 26 01:35:45 2006 @@ -1865,7 +1865,7 @@ mechanism using the quote C, followed by a block intended to represent an AST: -return q:code { say $a }; +return q:code { say "foo" }; Modifiers to the C<:code> adverb can modify the operation: @@ -1873,11 +1873,42 @@ :lang(Ruby)# Default :lang($?PARSER) :unquote<[: :]># Default "triple rule" -Within a quasiquote, variable and function names resolve first of -all according to the lexical scope of the macro definition, and if -unrecognized in that scope, are assumed to be bound from the scope -of the macro call each time it is called. If they cannot be bound -from the scope of the macro call, a compile-time exception is thrown. +Within a quasiquote, variable and function names resolve according +to the lexical scope of the macro definition. Unrecognized symbols raise +errors when the macro is being compiled, I when it's being used. + +To make a symbol resolve to the (partially compiled) scope of the macro +call, use the C pseudo-package: + +macro moose () { q:code { $COMPILING::x } } + +moose(); # macro-call-time error +my $x; +moose(); # resolves to 'my $x' + +If you want to mention symbols from the scope of the macro call, use the +import syntax as modifiers to C<:code>: + +:COMPILING<$x> # $x always refers to $x in caller's scope +:COMPILING # All free variables fallback to caller's scope + +If those symbols do not exist in the scope of the compiling scope, a +compile-time exception is thrown at macro call time. + +Similarly, in the macro body you may either refer to the C<$x> declared in the +scope of the macro call as C<$COMPILING::x>, or bind to them explicitly: + +my $x := $COMPILING::x; + +You may also use an import list to bind multiple symbols into the +macro's lexical scope: + +require COMPILING <$x $y $z>; + +Note that you need to use the run-time C<:=> and C forms, not C<::=> +and C, because the macro caller's compile-time is the macro's runtime. + +=head2 Splicing Bare AST variables (such as the arguments to the macro) may not be spliced directly into a quasiquote because they would be taken as
[svn:perl6-synopsis] r7876 - doc/trunk/design/syn
Author: autrijus Date: Sun Feb 26 07:45:08 2006 New Revision: 7876 Modified: doc/trunk/design/syn/S03.pod doc/trunk/design/syn/S04.pod doc/trunk/design/syn/S05.pod doc/trunk/design/syn/S06.pod doc/trunk/design/syn/S09.pod doc/trunk/design/syn/S12.pod Log: * podchecking all the S*. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podSun Feb 26 07:45:08 2006 @@ -172,9 +172,9 @@ When using a unary operator, only put it on the operand's side: @negatives = -« @positives; - + @positions »++;# Increment all positions - + @objects ».run(); ("f","oo","bar")».chars; # (1,2,3) @@ -263,7 +263,7 @@ allowing multiple operands. if 3 < $roll <= 6 { print "High roll" } - + if 1 <= $roll1 == $roll2 <= 6 { print "Doubles!" } Note: any operator beginning with C<< < >> must have whitespace Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podSun Feb 26 07:45:08 2006 @@ -678,7 +678,7 @@ print if $foo -since C<< prefix:> > would hide C<< statement_modifier: >>. +since C<< prefix: >> would hide C<< statement_modifier: >>. =head1 Smart matching Modified: doc/trunk/design/syn/S05.pod == --- doc/trunk/design/syn/S05.pod(original) +++ doc/trunk/design/syn/S05.podSun Feb 26 07:45:08 2006 @@ -1123,7 +1123,7 @@ may be of any type, not just a string. You may also capture a subset of the match as the result object using -the C<< <(...)> construct: +the C<< <(...)> >> construct: "foo123bar" ~~ / foo <( \d+ )> bar / say $();# says 123 Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podSun Feb 26 07:45:08 2006 @@ -191,7 +191,7 @@ my $lastval; sub lastval () is rw { return $lastval } - + or the result of some nested call to an lvalue subroutine: sub prevval () is rw { return lastval() } @@ -634,7 +634,7 @@ so you can refer to it within the body. sub foo(*%flag, [EMAIL PROTECTED]) {...} - + foo(:flag{ a => 1 }, :data[ 1, 2, 3 ]); # %flag has elements (flag => (a => 1)) and (data => [1,2,3]) # @data has nothing @@ -1027,9 +1027,9 @@ my $addr := delete %guest_data; ... } - + you can get the same effect with: - + sub register ({:$name, :$addr, *%guest_data}, $room_num) { ... } Modified: doc/trunk/design/syn/S09.pod == --- doc/trunk/design/syn/S09.pod(original) +++ doc/trunk/design/syn/S09.podSun Feb 26 07:45:08 2006 @@ -503,30 +503,30 @@ single junction of the same species as the junctive argument. If two or more arguments are junctive, then the argument that is chosen to be "autothreaded" is: - + =over - + =item * - + the left-most conjunction or injunction (if any), or else - + =item * - + the left-most abjunction or disjunction - + =back - + with the tests applied in that order. - + Each of the resulting set of calls is then recursively autothreaded until no more junctive arguments remain. That is: - + substr("camel", 0|1, 2&3) - + -> all( substr("camel", 0|1, 2), # autothread the conjunctive arg substr("camel", 0|1, 3) ) -
[svn:perl6-synopsis] r7877 - doc/trunk/design/syn
Author: autrijus Date: Sun Feb 26 07:48:47 2006 New Revision: 7877 Modified: doc/trunk/design/syn/S02.pod Log: * S02: Non-qualified variables, such as $x and &f, _always_ refers to lexicals under default strictitude, because we can now say: our $x; # brings from package scope use GLOBAL <$IN>; # brings from global scope Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podSun Feb 26 07:48:47 2006 @@ -240,6 +240,8 @@ =head1 Names and Variables +=over 4 + =item * The C<$pkg'var> syntax is dead. Use C<$pkg::var> instead. @@ -549,11 +551,26 @@ then from inner packages to outer. Variable names are searched for from inner lexical scopes to outer, but unlike package names are looked for in only the current package and the global package. + The global namespace is the last place it looks in either case. You must use the C<*> (or C) package on the front of the string argument to force the search to start in the global namespace. -Use the C pseudopackage to limit the scopes to lexical, and C -to limit the scopes to package. + +Use the C pseudopackage to limit the lookup to the current lexical +scope, and C to limit the scopes to the current package scope. + +=item * + +When "strict" is in effect (which is the default except for one-liners), +non-qualified variables (such as C<$x> and C<@y>) are only looked up from +lexical scopes, but never from package scopes. + +To bind package variables into a lexical scope, simply say C. +To bind global variables into a lexical scope, predeclare them with C: + +use GLOBAL <$IN $OUT>; + +Or just refer to them as C<$*IN> and C<$*OUT>. =item *
[svn:perl6-synopsis] r7898 - doc/trunk/design/syn
Author: autrijus Date: Tue Feb 28 07:22:23 2006 New Revision: 7898 Modified: doc/trunk/design/syn/S05.pod Log: * S05: Generalizing +$/ and ~$/ delegating to $(), by stipulating that all explicit coercion forms, except for boolean, dispatch from Match to its result object. Modified: doc/trunk/design/syn/S05.pod == --- doc/trunk/design/syn/S05.pod(original) +++ doc/trunk/design/syn/S05.podTue Feb 28 07:22:23 2006 @@ -588,6 +588,17 @@ The closure is guaranteed to be run at the canonical time. +An B return from the closure binds the I for +this match, ignores the rest of the current rule, and reports success: + + / (\d) { return $0.sqrt } NotReached /; + +This has the effect of capturing the square root of the numified string, +instead of the string. The C part is not reached. + +These closures are invoked as anonymous methods on the C object. +See L below for more about result objects. + =item * A leading C<&> interpolates the return value of a subroutine call as @@ -1115,7 +1126,7 @@ my $moose = m:{ -{ return Moose.new( body => $().attach($()) ) } +{ return Moose.new( body => $().attach($) ) } # match succeeds -- ignore the rest of the rule }.(); @@ -1131,6 +1142,16 @@ In this case the result object is always a string when doing string matching, and a list of one or more elements when doing array matching. +Additionally, the C object delegates its C calls +(such as C<+$match> and C<~$match>) to its underlying result object. +The only exception is that C handles boolean coercion itself, +which returns whether the match had succeeded. + +This means that these two work the same: + +/ { $.() as Moose } / +/ { $as Moose } / + =item * When used as an array, a Match object pretends to be an array of all
[svn:perl6-synopsis] r8122 - doc/trunk/design/syn
Author: autrijus Date: Sun Mar 12 05:15:15 2006 New Revision: 8122 Modified: doc/trunk/design/syn/S12.pod Log: * S12: private methods are no longer .:meth, but !meth. Modified: doc/trunk/design/syn/S12.pod == --- doc/trunk/design/syn/S12.pod(original) +++ doc/trunk/design/syn/S12.podSun Mar 12 05:15:15 2006 @@ -552,7 +552,7 @@ @object».*meth(@args) # calls all methods (0 or more) on each @object».+meth(@args) # calls all methods (1 or more) on each @object».=meth(@args) # calls mutator method on each -@object».:meth(@args) # calls private method on each +@object»!meth(@args) # calls private method on each Hyperoperators treat a junction as a scalar value, so saying:
[svn:perl6-synopsis] r8123 - doc/trunk/design/syn
Author: autrijus Date: Sun Mar 12 05:16:44 2006 New Revision: 8123 Modified: doc/trunk/design/syn/S06.pod Log: * S06: Patch from bsb++ to make macros hygienic by default, with TimToady++'s idea for q:code(:COMPILING) to denote unhygienicness. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podSun Mar 12 05:16:44 2006 @@ -1985,6 +1985,11 @@ return q:code < say $a + <<< $ast >>> > return q:code ( say $a + ((( $ast ))) ) +The delimiters don't have to be bracketing quotes, but the following +is probably to be construed as Bad Style: + +return q:code / say $a + /// $ast /// / + (Note to implementors: this must not be implemented by finding the final closing delimiter and preprocessing, or we'll violate our one-pass parsing rule. Perl 6 parsing rules are parameterized to know @@ -1997,12 +2002,7 @@ inner expression, the inner parser rule is parameterized to know that C<}}}> or whatever is its closing delimiter.) -The delimiters don't have to be bracketing quotes, but the following -is probably to be construed as Bad Style: - -return q:code / say $a + /// $ast /// / - -Dequoted expressions are inserted appropriately depending on the +Unquoted expressions are inserted appropriately depending on the type of the variable, which may be either a syntax tree or a string. (Again, syntax tree is preferred.) The case is similar to that of a macro called from within the quasiquote, insofar as reparsing only @@ -2020,10 +2020,20 @@ (Generally, a term expects a following postfix or infix operator, and an operator expects a following term or prefix operator.) -A quasiquote is not a block (even if the delimiters are curlies), -so any declaration of a variable is taken to be part of the block -surrounding the macro call location. Add your own {...} if you want -a block to surround your declarations. +Quasiquotes default to hygienic lexical scoping, just like closures. +The visibility of lexical variables is limited to the q:code expression +by default. A variable declaration can be made externally visible using +the C pseudo-package. Individual variables can be made visible, +or all top-level variable declarations can be exposed using the +C form. + +Both examples below will add C<$new_variable> to the lexical scope of +the macro call: + + q:code { my $COMPILING::new_variable; my $private_var; ... } + q:code(:COMPILING) { my $new_variable; { my $private_var; ... } } + +(Note that C<:COMPILING> has additional effects described in L.) =head1 Other matters
[svn:perl6-synopsis] r8501 - doc/trunk/design/syn
Author: autrijus Date: Fri Mar 31 03:13:46 2006 New Revision: 8501 Modified: doc/trunk/design/syn/S06.pod Log: * I don't believe in a Ref type... (\3 now just means \(3), constructing an Arguments object.) Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podFri Mar 31 03:13:46 2006 @@ -1259,7 +1259,6 @@ Str Perl string (Unicode semantics) Num Perl number Complex Perl complex number -Ref Perl reference BoolPerl boolean Array Perl array HashPerl hash
[svn:perl6-synopsis] r8502 - doc/trunk/design/syn
Author: autrijus Date: Fri Mar 31 03:16:08 2006 New Revision: 8502 Modified: doc/trunk/design/syn/S02.pod Log: * S02: Explicit division of immutable/mutable/native types. * S02: "Int"'s bigint autopromotion must not change its underlying type (i.e. "int" -> "BigInt"), and must support Inf/NaN. * S02: Unify terminology: "value"/"natural"/"native" etc is now just "native" for describing lower-case classes. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podFri Mar 31 03:16:08 2006 @@ -177,22 +177,26 @@ my int @array is MyArray; -you are declaring that the elements of C<@array> are integers, +you are declaring that the elements of C<@array> are native integers, but that the array itself is implemented by the C class. Untyped arrays and hashes are still perfectly acceptable, but have the same performance issues they have in Perl 5. =item * -Built-in object types start with an uppercase letter: C, C, -C, C, C, C, C, C, C, -C and C. Non-object (value) types are lowercase: C, -C, C, C, C, and C. Value types are -primarily intended for declaring compact array storage. However, Perl -will try to make those look like their corresponding uppercase types if -you treat them that way. (In other words, it does autoboxing. Note, -however, that sometimes repeated autoboxing can slow your program more -than the native type can speed it up.) +Built-in object types start with an uppercase letter. This includes +immutable types (e.g. C, C, C, C, C, +C, C, C, C, C, C), as well as +mutable (container) types, such as C, C, C, +C, C, etc. + +Non-object (native) types are lowercase: C, C, C, +C, C, C. Native types are primarily intended for +declaring compact array storage. However, Perl will try to make those +look like their corresponding uppercase types if you treat them that way. +(In other words, it does autoboxing. Note, however, that sometimes +repeated autoboxing can slow your program more than the native type +can speed it up.) =item * @@ -213,14 +217,20 @@ Perl 6 intrinsically supports big integers and rationals through its system of type declarations. C automatically supports promotion -to arbitrary precision. (C may support arbitrary-precision -floating-point arithmatic, but is not required to unless we can do -so portably and efficiently.) C supports arbitrary precision -rational arithmetic. Value types like C and C imply -the natural machine representation for integers and floating-point -numbers, respectively, and do not promote to arbitrary precision. -Untyped numeric scalars use C and C semantics rather than -C and C. +to arbitrary precision, as well as holding C and C values. + +(C may support arbitrary-precision floating-point arithmatic, but +is not required to unless we can do so portably and efficiently.) + +C supports arbitrary precision rational arithmetic. However, +dividing two C objects produces fractionals as C objects by +default, not C objects. You can override this behavior with +a pragma. + +Lower-case types like C and C imply the native machine +representation for integers and floating-point numbers, respectively, and +do not promote to arbitrary precision. Untyped numeric scalars use C +and C semantics rather than C and C. =item * @@ -365,25 +375,27 @@ =item * -An argument list object (C) may be created with backslashed parens: +An argument list object (C) may be created with backslashed parens: $args = \(1,2,3,:mice) -A C's values are parsed as ordinary expressions. By default a -C is lazy. This interacts oddly with the fact that a C -is immutable in the abstract. Once all of a C's arguments are -fully evaluated (which happens at compile time when all the arguments -are constants), the C functions as an immutable tuple type. -Before that moment, the eventual value may well be unknown. All we -know is that 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 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. +Values in C values are parsed as ordinary expressions, marked as +positional, named, to-be-flattened, and so on. + +Like C objects, C are immutable in the abstract, but +evaluates its arguments lazily. Before everything inside a C are +fully evaluated (which happens at compile time when all the arguments are +constants), the eventual value may well be unknown. All we know is that 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 +or slices. How these
[svn:perl6-synopsis] r8503 - doc/trunk/design/syn
Author: autrijus Date: Fri Mar 31 03:21:59 2006 New Revision: 8503 Modified: doc/trunk/design/syn/S02.pod Log: * upon further discussion, in the interest of optimizability, Code/Block is now immutable and only Routine/Subroutine/Methods are mutables. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podFri Mar 31 03:21:59 2006 @@ -186,9 +186,9 @@ Built-in object types start with an uppercase letter. This includes immutable types (e.g. C, C, C, C, C, -C, C, C, C, C, C), as well as -mutable (container) types, such as C, C, C, -C, C, etc. +C, C, C, C, C, B, C, +C), as well as mutable (container) types, such as C, +C, C, C, C, etc. Non-object (native) types are lowercase: C, C, C, C, C, C. Native types are primarily intended for
[svn:perl6-synopsis] r8504 - doc/trunk/design/syn
Author: autrijus Date: Fri Mar 31 04:07:40 2006 New Revision: 8504 Modified: doc/trunk/design/syn/S06.pod Log: * S06: Updated built-in classes: - bring in "uint" from S09 (boxes to Int) - new "Buf" class to represent subscriptable byte streams - "Arguments" and "Signature" from S02 - explicit "Scalar" container type from other places in S06 Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podFri Mar 31 04:07:40 2006 @@ -1242,44 +1242,55 @@ Note that placeholder variables syntactically cannot have type constraints. -=head1 Types +=head1 Built-in Types These are some of the standard type names in Perl 6 (at least this week): +=head2 Native types + bit single native bit -int native integer -buf native 8-bit string (sequence of 8-bit integers, no Unicode) -str native string (sequence of arbitrary integers, no Unicode) +int native signed integer +uintnative unsigned integer (autoboxes to Int) +buf native bytes (finite sequence of "uint8"s, no Unicode) +str native string (finite sequence of native integers, no Unicode) num native floating point complexnative complex number -ref native pointer boolnative boolean + +=head2 Immutable types + Bit Perl single bit (allows traits, aliasing, undef, etc.) -Int Perl integer (allows traits, aliasing, undef, etc.) -Str Perl string (Unicode semantics) +Int Perl integer (allows Inf/NaN, arbitrary precision, etc.) +Buf Perl buffer (possibly lazy list of bytes, can be subscripted) +Str Perl string (finite sequence of Unicode characters) Num Perl number Complex Perl complex number BoolPerl boolean +CodeBase class for all executable objects +Block Base class for all embedded executable objects +ListLazy Perl list +Tuple Completely evaluated (hence immutable) list +Signature Function parameters (left-hand side of a binding) +Arguments Function call arguments (right-hand side of a binding) + +=head2 Mutable types + Array Perl array HashPerl hash +Scalar Perl scalar IO Perl filehandle -CodeBase class for all executable objects Routine Base class for all nameable executable objects Sub Perl subroutine Method Perl method Submethod Perl subroutine acting like a method Macro Perl compile-time subroutine RulePerl pattern -Block Base class for all embedded executable objects Package Perl 5 compatible namespace Module Perl 6 standard namespace Class Perl 6 standard class namespace RolePerl 6 standard generic interface/implementation Object Perl 6 object Grammar Perl 6 pattern matching namespace -ListLazy Perl list -Tuple Completely evaluated (hence immutable) list - =head2 Value types @@ -1784,7 +1795,7 @@ =head2 Wrapping -Every subroutine has a C<.wrap> method. This method expects a single +Every C object has a C<.wrap> method. This method expects a single argument consisting of a block, closure, or subroutine. That argument must contain a call to the special C function: @@ -1860,7 +1871,7 @@ =head2 Currying -Every subroutine has an C<.assuming> method. This method does a partial +Every C object has an C<.assuming> method. This method does a partial binding of a set of arguments to a signature and returns a new function that takes only the remaining arguments.
[svn:perl6-synopsis] r8505 - doc/trunk/design/syn
Author: autrijus Date: Fri Mar 31 04:10:36 2006 New Revision: 8505 Modified: doc/trunk/design/syn/S09.pod Log: * excise the "ref" from S09 Modified: doc/trunk/design/syn/S09.pod == --- doc/trunk/design/syn/S09.pod(original) +++ doc/trunk/design/syn/S09.podFri Mar 31 04:10:36 2006 @@ -101,8 +101,8 @@ my num @nums; my int4 @nybbles; my buf @buffers; -my ref[Array] @ragged2d; my complex128 @longdoublecomplex; +my Array @ragged2d; the presence of a low-level type tells Perl that it is free to implement the array with "compact storage", that is, with a chunk
[svn:perl6-synopsis] r8511 - doc/trunk/design/syn
Author: autrijus Date: Fri Mar 31 07:02:49 2006 New Revision: 8511 Modified: doc/trunk/design/syn/S06.pod Log: * S06: note that all native types autobox to their uppercased counterparts. Nicholas++ for asking. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podFri Mar 31 07:02:49 2006 @@ -1244,10 +1244,11 @@ =head1 Built-in Types -These are some of the standard type names in Perl 6 (at least this week): - =head2 Native types +Values with these types autoboxes to their uppercase counterparts when +you treat them as objects: + bit single native bit int native signed integer uintnative unsigned integer (autoboxes to Int)
[svn:perl6-synopsis] r8520 - doc/trunk/design/syn
Author: autrijus Date: Sat Apr 1 10:32:53 2006 New Revision: 8520 Modified: doc/trunk/design/syn/S02.pod Log: * S02: destill the compoments of an Arguments object, and specify the $() @() %() &() casting forms for them. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podSat Apr 1 10:32:53 2006 @@ -14,7 +14,7 @@ Date: 10 Aug 2004 Last Modified: 1 Apr 2006 Number: 2 - Version: 18 + Version: 19 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -393,6 +393,17 @@ bound to. Some bindings are sensitive to multiple dimensions while others are not. +You may cast C to other types with a prefix sigil operator: + +$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 Code" or "Hash($args)" + +Casted as an array, you can access to all positionals. Casted as a hash, all +nameds. As a scalar, the invocant. As a code, the slurpy nameless block. + =item * A signature object (C) may be created with coloned parens: @@ -430,7 +441,7 @@ &foo:(Int,Num) It still just returns a function reference. A call may also be partially -applied by using a tuple literal as a postfix operator: +applied by using an argument list literal as a postfix operator: &foo\(1,2,3,:mice)
[svn:perl6-synopsis] r8521 - doc/trunk/design/syn
Author: autrijus Date: Sat Apr 1 10:34:41 2006 New Revision: 8521 Modified: doc/trunk/design/syn/S03.pod Log: * S03: Value-type semantics; $obj.id.true disambiguates between prototypes and instances; user-defined value objects has to return some builtin values as their .id. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podSat Apr 1 10:34:41 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 8 Mar 2004 - Last Modified: 25 Feb 2006 + Last Modified: 1 Apr 2006 Number: 3 - Version: 13 + Version: 14 =head1 Operator renaming @@ -84,14 +84,22 @@ types, checks whether they have the same identity value. For reference types that do not define an identity, the reference itself is used (eg. it is not true that C<[1,2] === [1,2]>, but it is true that C<[EMAIL PROTECTED] === [EMAIL PROTECTED]>). -Any reference type may pretend to be a value type by defining a C<.id> method. -(It may also overload C<< infix:<===> >> for more efficient comparison of -any two objects of that type, but it had better return the same result as if -the two identity values had been generated and compared.) 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>. + +Any reference type may pretend to be a value type by defining a C<.id> method +which returns a built-in value, i.e. an immutable object or a native value, +as specified in S06. + +Because Perl 6 uses a false C<.id> to signify a non-instantiated prototype, +all instances should arrange to return a C<.id> that boolifies to true. + +A class may also overload C<< infix:<===> >> for more efficient comparison of +any two objects of that type, but it must return the same result as if +the two identity values had been generated and compared. + +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>. Note also that, while string hashes use C semantics by default, object hashes use C<===> semantics.
[svn:perl6-synopsis] r8522 - doc/trunk/design/syn
Author: autrijus Date: Sat Apr 1 10:35:35 2006 New Revision: 8522 Modified: doc/trunk/design/syn/S04.pod Log: * S04: Specify "fail" semantics in detail, and the relationship to the environmental $! variable. Handling and propagation of "unthrown exceptions" clarified. Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podSat Apr 1 10:35:35 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 19 Aug 2004 - Last Modified: 28 Mar 2006 + Last Modified: 1 Apr 2006 Number: 4 - Version: 11 + Version: 12 This document summarizes Apocalypse 4, which covers the block and statement syntax of Perl. @@ -464,38 +464,34 @@ =head1 Exceptions 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. Unlike in -Perl 5, these may be "interesting" values of undef that contain -information about the error. If you try to use an undefined value, -that information can then be conveyed to the user. In essence, undef -can be an unthrown exception object that just happens to return 0 when -you ask it whether it's defined or it's true. Since C<$!> contains the -current error code, saying C will turn an unthrown exception -into a thrown exception. (A bare C does the same.) +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<$!> and knows whether it has been handled or not. + +If you test a C for C<.id>, C<.defined> or C<.true>, it causes +C<$!> to mark the exception as I, and acts as a harmless C +value thereafter. Any other use of the C will throw its associated +exception immediately. + +Because the C variable C<$!> contains all exceptions collected in the +current lexical scope, saying C will throw all exceptions, +whether they were handled or not. A bare C/C takes C<$!> as the +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. You can cause built-ins to automatically throw exceptions on failure using use fatal; -The C function responds to the caller's "use fatal" state. It +The C function responds to the caller's C state. It either returns an unthrown exception, or throws the exception. -If an exception is raised while C<$!> already contains an exception -that is active and "unhandled", no information is discarded. The old -exception is pushed onto the exception stack within the new exception, -which is then bound to C<$!> and, hopefully, propagated. The default -printout for the new exception should include the old exception -information so that the user can trace back to the original error. -(Likewise, rethrown exceptions add information about how the exception -is propagated.) The exception stack within C<$!> is available as -C<$![]>. - -Exception objects are born "unhandled". The C<$!> object keeps track of -whether it's currently "handled" or "unhandled". The exception in C<$!> still -exists after it has been caught, but catching it marks it as handled -if any of the cases in the switch matched. Handled exceptions don't -require their information to be preserved if another exception occurs. - =head1 Closure traits A C block is just a trait of the closure containing it. Other
[svn:perl6-synopsis] r8523 - doc/trunk/design/syn
Author: autrijus Date: Sat Apr 1 10:36:25 2006 New Revision: 8523 Modified: doc/trunk/design/syn/S05.pod Log: * S05: $/.() is now $$/. $() still works as $$/, and we have @() %() forms that maps to @$/ and %$/. Modified: doc/trunk/design/syn/S05.pod == --- doc/trunk/design/syn/S05.pod(original) +++ doc/trunk/design/syn/S05.podSat Apr 1 10:36:25 2006 @@ -13,9 +13,9 @@ Maintainer: Patrick Michaud <[EMAIL PROTECTED]> Date: 24 Jun 2002 - Last Modified: 25 Feb 2006 + Last Modified: 1 Apr 2006 Number: 5 - Version: 12 + Version: 13 This document summarizes Apocalypse 5, which is about the new regex syntax. We now try to call them "rules" because they haven't been @@ -1120,18 +1120,18 @@ =item * -When called as a closure, a Match object evaluates to its underlying +When used as a scalar, a Match object evaluates to its underlying result object. Usually this is just the entire match string, but you can override that by calling C inside a rule: -my $moose = m:{ +my $moose = $(m:{ { return Moose.new( body => $().attach($) ) } # match succeeds -- ignore the rest of the rule -}.(); +}); -C<$()> is a shorthand for C<$/.()> or C<$/()>. The result object -may be of any type, not just a string. +C<$()> is a shorthand for C<$($/)>. The result object may be of any type, +not just a string. You may also capture a subset of the match as the result object using the C<< <(...)> >> construct: @@ -1149,8 +1149,8 @@ This means that these two work the same: -/ { $.() as Moose } / -/ { $as Moose } / +/ { return $$ as Moose } / +/ { return $ as Moose } / =item * @@ -1172,8 +1172,13 @@ $mystring = "{ m:w/ (\S+) => (\S+)/[] }"; +Or cast it into an array: + + $mystring = "@( m:w/ (\S+) => (\S+)/ )"; + Note that, as a scalar variable, C<$/> doesn't automatically flatten -in list context. Use C<@$/> or C<$/[]> to flatten as an array. +in list context. Use C<@()> as a shorthand for C<@($/)> to flatten +the positional captures under list context. =item * @@ -1185,8 +1190,8 @@ capture datatypes.) Note that, as a scalar variable, C<$/> doesn't automatically flatten -in list context. Use C<%$/> or C<$/{}> to flatten as a hash, or bind -it to a variable of the appropriate type. +in list context. Use C<%()> as a shorthand for C<%($/)> to flatten as a +hash, or bind it to a variable of the appropriate type. =item *
[svn:perl6-synopsis] r8524 - doc/trunk/design/syn
Author: autrijus Date: Sat Apr 1 10:43:08 2006 New Revision: 8524 Modified: doc/trunk/design/syn/S06.pod Log: * S06: De-mystifying the logic for named arguments. "*$x" is now just casting $x as an Arguments object. Differ between "foo;" and "foo();" via zero-dimensional slices. Split the semantic of "Undef" and "Failure" types. Add a more comprehensive list of builtin classes. Allow named returns via the "return" function. Routine's .wrap semantic is now much clarified. &?SUB is renamed to &?ROUTINE; remove the $?BLOCKLABEL and $?SUBNAME magicals (they are now just methods); clarify the &?BLOCK means the immediate block, even if it's part of a routine. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podSat Apr 1 10:43:08 2006 @@ -15,7 +15,7 @@ Date: 21 Mar 2003 Last Modified: 1 Apr 2006 Number: 6 - Version: 20 + Version: 21 This document summarizes Apocalypse 6, which covers subroutines and the @@ -370,7 +370,6 @@ subscript instead of the sigil. The C<:> is not functioning as an operator here, but as a modifier of the following token: - doit %hash:,1,2,3; doit %hash:{'b'},1,2,3; @@ -390,15 +389,15 @@ C<:p> adverb may be placed on any hash reference to make it mean "pairs" instead of "values".) -Pairs are recognized syntactically at the call level and mystically -transformed into special C objects that may be bound to -positionals only by name, not as ordinary positional C objects. -Leftover special C objects can be slurped into a slurpy hash. +Pair constructors are recognized syntactically at the call level and +put into the named slot of the C structure. Hence they may be +bound to positionals only by name, not as ordinary positional C +objects. Leftover named arguments can be slurped into a slurpy hash. After the positional and named arguments, all the rest of the arguments are taken to be list arguments. Any pairs within the list are taken -to be list elements rather than named arguments, and mystically show -up as C arguments even if the compiler marked them as C. +to be list elements rather than named arguments, and show up as C +arguments even if the compiler marked them as named. It is possible that named pairs are not really a separate type; it would be sufficient to have a bit somewhere in the Pair that can be @@ -498,7 +497,7 @@ $comparison = numcmp(:y(7), :x(2)); Passing the wrong number of required arguments to a normal subroutine -is a fatal error. Passing a NamedArg that cannot be bound to a normal +is a fatal error. Passing a named argument that cannot be bound to a normal subroutine is also a fatal error. (Methods are different.) The number of required parameters a subroutine has can be determined by @@ -664,11 +663,14 @@ =head2 Argument list binding -The underlying argument list (List) object may be bound to a single -scalar parameter marked with a C<\>: +The underlying C object may be bound to a single scalar +parameter marked with a C<\>. -sub foo (\$args) { say $args.perl; &bar.call(*$args); } sub bar ($a,$b,$c,:$mice) { say $mice } +sub foo (\$args) { say $args.perl; &bar.call($args); } + +The C<.call> method of C objects accepts a single C +object, and calls it without introducing a C frame. foo 1,2,3,:mice;# says "\(1,2,3,:mice)" then "blind" @@ -685,16 +687,27 @@ =head2 Flattening argument lists -The unary prefix operator C<*> dereferences its operand (which allows -the elements of an array or iterator or List or Tuple to be used as -part of an argument list). The C<*> operator also causes its operand -- -and any subsequent arguments in the argument list -- to be evaluated in -list context. It also turns off syntactic recognition of named pairs. -The eventual argument list will be parsed at call time for named pairs. -All contiguous pairs are treated as named arguments until the first -non-Pair, and the rest of the arguments are considered slurpy args. -[XXX still underspecified...] +The unary prefix operator C<*> casts a value to an C +object, then splices it into the argument list it occurs in. + +Casting C to C is a no-op: + +*(\(1, x=>2));# Arguments, becomes \(1, x=>2) + +C and C become named arguments: + +*(x=>1); # Pair, becomes \(x=>1) +*{x=>1, y=>2};# Hash, becomes \(x=>1, y=>2) + +C (also C, C, etc.) are simply turned into +positional arguments: +*(1,2,3); # Tuple, becomes \(1,2,3) +*(1..3); # Range, becomes \(1,2,3) +*(1..2, 3); # List, becomes \(1,2,3)
[svn:perl6-synopsis] r8525 - doc/trunk/design/syn
Author: autrijus Date: Sat Apr 1 10:43:58 2006 New Revision: 8525 Modified: doc/trunk/design/syn/S11.pod Log: * S11: Allow user-defined dynamic exportation with EXPORT routines, which assume the semantic from Damian's Perl6::Export::Attrs. The magical export dispatcher is now EXPORTALL. Modified: doc/trunk/design/syn/S11.pod == --- doc/trunk/design/syn/S11.pod(original) +++ doc/trunk/design/syn/S11.podSat Apr 1 10:43:58 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 27 Oct 2004 - Last Modified: 17 Mar 2006 + Last Modified: 1 Apr 2006 Number: 11 - Version: 10 + Version: 11 =head1 Overview @@ -105,7 +105,18 @@ } The C module will export C<&foo>, C<&bar> and C<&baz> by default; -calling C will import C<&bar> and C<&baz> at runtime. +calling C will export C<&bar> and C<&baz> at runtime +to the caller's package. + +=head1 Dynamic exportation + +The default C handles symbol exports by removing recognized +export items and tagsets from the argument list, then calls the C +subroutine in that module (if there is one), passing in the remaining +arguments. + +If the exporting module is actually a class, C will invoke its +C method with the class itself as the invocant. =head1 Compile-time Importation @@ -155,7 +166,7 @@ at runtime cannot import into the lexical scope: require Sense; -Sense.import; # goes to the OUR scope by default, not MY +Sense.EXPORTALL; # goes to the OUR scope by default, not MY =head1 Importing from a pseudo-package
[svn:perl6-synopsis] r8526 - doc/trunk/design/syn
Author: autrijus Date: Sat Apr 1 10:44:53 2006 New Revision: 8526 Modified: doc/trunk/design/syn/S12.pod Log: * S12: The "call" form can now be used to call the next MMD or SMD candidate. A "proto" declaration needs to happen before multis. Fix a misuse of ".call" method. Modified: doc/trunk/design/syn/S12.pod == --- doc/trunk/design/syn/S12.pod(original) +++ doc/trunk/design/syn/S12.podSat Apr 1 10:44:53 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 27 Oct 2004 - Last Modified: 23 Feb 2006 + Last Modified: 1 Apr 2006 Number: 12 - Version: 10 + Version: 11 =head1 Overview @@ -542,6 +542,13 @@ :omit(Selector) # only classes that don't match selector :include(Selector) # only classes that match selector +In addition to C, the special function C dispatches +to the next candidate, possibly with a new argument list: + +call; # calls with the original arguments +call(); # calls with no arguments +call(1,2,3);# calls with a different set of arguments + =head1 Parallel dispatch Any of the method call forms may be turned into a hyperoperator by @@ -681,6 +688,8 @@ The C keyword is optional after either C or C. +A C declaration must come before any matching multis, if at all. + =head1 Roles Classes are primarily in charge of object management, and only @@ -704,7 +713,7 @@ method feed ($food) { $food.open_can; $food.put_in_bowl; - self.call; + self.some_other_method; } }
[svn:perl6-synopsis] r8527 - doc/trunk/design/syn
Author: autrijus Date: Sat Apr 1 11:56:07 2006 New Revision: 8527 Modified: doc/trunk/design/syn/S02.pod Log: * Fix typo as reported by Joe Gottman. Explicitly specify the rvalue-ness, interpolated-ness, and default-to-match-object-ness of prefix sigil operators. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podSat Apr 1 11:56:07 2006 @@ -399,11 +399,16 @@ $$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 Code" or "Hash($args)" +&$args; # same as '$args as Code" or "Code($args)" Casted as an array, you can access to all positionals. Casted as a hash, all nameds. As a scalar, the invocant. As a code, the slurpy nameless block. +All prefix sigil operators accept one positional argument, evaluated in +scalar context as a rvalue. They can interpolate in strings if called with +parentheses. The C<$()>, C<@()> and C<%()> forms defaults to C<$/> as the +implicit argument. + =item * A signature object (C) may be created with coloned parens:
[svn:perl6-synopsis] r8528 - doc/trunk/design/syn
Author: autrijus Date: Sat Apr 1 14:01:16 2006 New Revision: 8528 Modified: doc/trunk/design/syn/S06.pod doc/trunk/design/syn/S12.pod doc/trunk/design/syn/S13.pod Log: * S06+S12: Split the old "multiple-dispatch" into two distinct ideas: - "Method call" vs "Subroutine call" - "Multiple dispatch" vs "Single dispatch" A multi-method or multi-sub is simply a method/sub that has variants, and has nothing to do with transcending class boundaries. With a multi-sub, it's the sub-ness that transcends class boundaries, not the multi-ness. Consequently, $x.foo(3) still falls back to foo($x, 3) if there is not such method, but foo($x, 3) won't magically call the "foo" method even if it's declared as a multi-method. To get the old magical dual behaviour, use "multi submethod". "multi foo" within a class/role now means "multi method foo". Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podSat Apr 1 14:01:16 2006 @@ -34,13 +34,6 @@ subroutines masquerading as methods. They have an invocant and belong to a particular kind or class. -B (keyword: C) are routines that transcend class -boundaries, and can have one or more invocants. - -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. - B (keyword: C) are methods (of a grammar) that perform pattern matching. Their associated block has a special syntax (see Synopsis 5). @@ -52,6 +45,32 @@ as they are parsed (i.e. at compile-time). Macros may return another source code string or a parse-tree. +=head1 Routine modifiers + +B (keyword: C) are routines that can have multiple +variants that shares the same name, selected by arity, types, or some +other constraints. They may have multliple invocants. + +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 modifier keyword may occur before the routine keyword in a named routine: + +proto sub foo {...} +multi sub foo {...} +proto method bar {...} +multi method bar {...} + +If the routine keyword is omitted, it defaults to C inside a +class or role, and C inside a module or package. + +class C { +multi foo {...} # multi method foo +} +module M { +multi bar {...} # multi sub bar +} =head2 Named subroutines @@ -427,7 +446,7 @@ =head2 Invocant parameters -A method invocant is specified as the first parameter in the parameter +A method invocant may be specified as the first parameter in the parameter list, with a colon (rather than a comma) immediately after it: method get_name ($self:) {...} @@ -442,31 +461,36 @@ Multimethod and multisub invocants are specified at the start of the parameter list, with a colon terminating the list of invocants: -multi sub handle_event ($window, $event: $mode) {...}# two invocants +multi sub handle_event ($window, $event: $mode) {...} # two invocants +multi method set_name ($self, $name: $nick) {...} # two invocants -Multi invocant arguments are passed positionally, though the first -invocant can be passed via the method call syntax if the multi happens -to be defined as a multi method within the class of the first invocant. - -# Multimethod calls... -handle_event($w, $e, $m); -$w.handle_event($e, $m); +If the parameter list for a C contains no colon to delimit +the list of invocant parameters, then all positional parameters are +considered invocants. If it's a C and C, +an additional implicit unamed C invocant is prepended to the +signature list. + +For the purpose of matching positional arguments against invocant parameters, +the invocant argument passed via the method call syntax is considered the +first positional argument: + +handle_event($w, $e, $m); # calls the multi sub +$w.handle_event($e, $m);# ditto, but only if there is no +# suitable $w.handle_event method Invocants may also be passed using the indirect object syntax, with a colon after them. The colon is just a special form of the comma, and has the same precedence: -# Indirect method call... -set_name $obj: "Sam"; - -# Indirect multimethod call... -handle_event $w, $e: $m; +set_name $obj: "Sam"; # try $obj.set_name("Sam") first, then +# fall-back to set_name($obj, "Sam") +$obj.set_name("Sam"); # same as the above Passing too many or too few invocants is a fatal error if no matching definition can be found.
[svn:perl6-synopsis] r8529 - doc/trunk/design/syn
Author: autrijus Date: Sat Apr 1 14:07:20 2006 New Revision: 8529 Modified: doc/trunk/design/syn/S06.pod doc/trunk/design/syn/S12.pod doc/trunk/design/syn/S13.pod Log: * Bump version for the affected S06, S12 and S13. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podSat Apr 1 14:07:20 2006 @@ -15,7 +15,7 @@ Date: 21 Mar 2003 Last Modified: 1 Apr 2006 Number: 6 - Version: 21 + Version: 22 This document summarizes Apocalypse 6, which covers subroutines and the Modified: doc/trunk/design/syn/S12.pod == --- doc/trunk/design/syn/S12.pod(original) +++ doc/trunk/design/syn/S12.podSat Apr 1 14:07:20 2006 @@ -14,7 +14,7 @@ Date: 27 Oct 2004 Last Modified: 1 Apr 2006 Number: 12 - Version: 11 + Version: 12 =head1 Overview Modified: doc/trunk/design/syn/S13.pod == --- doc/trunk/design/syn/S13.pod(original) +++ doc/trunk/design/syn/S13.podSat Apr 1 14:07:20 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 2 Nov 2004 - Last Modified: 21 Aug 2005 + Last Modified: 1 Apr 2006 Number: 13 - Version: 3 + Version: 4 =head1 Overview
[svn:perl6-synopsis] r8531 - doc/trunk/design/syn
Author: autrijus Date: Sat Apr 1 19:35:01 2006 New Revision: 8531 Modified: doc/trunk/design/syn/S02.pod Log: * S02: typo fix and wording cleanup from Uri Guttman. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podSat Apr 1 19:35:01 2006 @@ -401,8 +401,9 @@ %$args; # same as '$args as Hash" or "Hash($args)" &$args; # same as '$args as Code" or "Code($args)" -Casted as an array, you can access to all positionals. Casted as a hash, all -nameds. As a scalar, the invocant. As a code, the slurpy nameless block. +When cast into an array, you can access all the positional arguments; Into a +hash, all named arguments; Into a scalar, the invocant; Into code, its slurpy +nameless block. All prefix sigil operators accept one positional argument, evaluated in scalar context as a rvalue. They can interpolate in strings if called with
[svn:perl6-synopsis] r8532 - doc/trunk/design/syn
Author: autrijus Date: Sat Apr 1 20:10:15 2006 New Revision: 8532 Modified: doc/trunk/design/syn/S02.pod Log: * upper/lowercase English nit fix for the last patch as suggested by TimToady Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podSat Apr 1 20:10:15 2006 @@ -401,8 +401,8 @@ %$args; # same as '$args as Hash" or "Hash($args)" &$args; # same as '$args as Code" or "Code($args)" -When cast into an array, you can access all the positional arguments; Into a -hash, all named arguments; Into a scalar, the invocant; Into code, its slurpy +When cast into an array, you can access all the positional arguments; into a +hash, all named arguments; into a scalar, the invocant; into code, its slurpy nameless block. All prefix sigil operators accept one positional argument, evaluated in
[svn:perl6-synopsis] r8533 - doc/trunk/design/syn
Author: autrijus Date: Sat Apr 1 20:46:57 2006 New Revision: 8533 Modified: doc/trunk/design/syn/S13.pod Log: * S13: specify type casting in the form of multi submethod *infix: which usually only cares about the class of its second invocant. Modified: doc/trunk/design/syn/S13.pod == --- doc/trunk/design/syn/S13.pod(original) +++ doc/trunk/design/syn/S13.podSat Apr 1 20:46:57 2006 @@ -116,3 +116,17 @@ this hash over a lexical scope, so you could have different policies on magical autogeneration. The default mappings correspond to the standard fallback mappings of Perl 5 overloading. + +=head1 Type Casting + +A class can use the C<< *infix: >> submethod to declare that its objects +can be casted to some other class: + +multi submethod *infix: (IO) { $*OUT } +multi submethod *infix: (Int) { 1 } +multi submethod *infix: (Str) { "Hello" } + +With the above declaration, C<$obj as "foo"> is equivalent to C<$obj as Str>, +because the multi dispatch cares only about the class. + +=cut
[svn:perl6-synopsis] r8534 - doc/trunk/design/syn
Author: autrijus Date: Sat Apr 1 20:49:18 2006 New Revision: 8534 Modified: doc/trunk/design/syn/S06.pod doc/trunk/design/syn/S12.pod Log: * Larry (aka TimToady in the previous commit log; sorry for spilling of IRC context) requested that "multi" should still only default to "multi sub" to reduce lookarounds. * Clarify that unary operators such as !$x always prefers method dispatch first, as $x.prefix. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podSat Apr 1 20:49:18 2006 @@ -62,15 +62,7 @@ proto method bar {...} multi method bar {...} -If the routine keyword is omitted, it defaults to C inside a -class or role, and C inside a module or package. - -class C { -multi foo {...} # multi method foo -} -module M { -multi bar {...} # multi sub bar -} +If the routine keyword is omitted, it defaults to C. =head2 Named subroutines @@ -467,7 +459,7 @@ If the parameter list for a C contains no colon to delimit the list of invocant parameters, then all positional parameters are considered invocants. If it's a C and C, -an additional implicit unamed C invocant is prepended to the +an additional implicit unnamed C invocant is prepended to the signature list. For the purpose of matching positional arguments against invocant parameters, Modified: doc/trunk/design/syn/S12.pod == --- doc/trunk/design/syn/S12.pod(original) +++ doc/trunk/design/syn/S12.podSat Apr 1 20:49:18 2006 @@ -651,6 +651,10 @@ close($handle,) +This applies to prefix unary operators as well: + +!$obj; # same as $obj.prefix: + A method call first considers methods (including multi-methods and submethods) from the class hierarchy of C<$handle>, and fails over to the subroutine dispatcher as a last resort only if no method can be found in the class @@ -686,9 +690,7 @@ The syntax for calling back to C is C<$obj!MyClass::meth()>. -Outside a class or a role, the C keyword is optional after either -C or C. Within a class or a role, the C keyword -is implied instead of C. +The C keyword is optional after either C or C. A C declaration must come before any matching multis, if at all.
[svn:perl6-synopsis] r8535 - doc/trunk/design/syn
Author: autrijus Date: Sat Apr 1 21:18:08 2006 New Revision: 8535 Modified: doc/trunk/design/syn/S06.pod Log: * S06: Rationalize the free mix of named and positional args. Positional pair arguments must _always_ be put in parentheses. Multiple named arguments with the same name can be concatenated into a @param now. $param gets the _last_ named argument, similar to how hash constructor and rule bindings work. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podSat Apr 1 21:18:08 2006 @@ -338,6 +338,8 @@ possible on those arguments that are bound to a final slurpy or arglist variable.) +=head2 Named arguments + Named arguments are recognized syntactically at the "comma" level. Pairs intended as positional arguments rather than named arguments must be isolated by extra parens: @@ -405,36 +407,34 @@ bound to positionals only by name, not as ordinary positional C objects. Leftover named arguments can be slurped into a slurpy hash. -After the positional and named arguments, all the rest of the arguments -are taken to be list arguments. Any pairs within the list are taken -to be list elements rather than named arguments, and show up as C -arguments even if the compiler marked them as named. - -It is possible that named pairs are not really a separate type; it -would be sufficient to have a bit somewhere in the Pair that can be -interrogated under the C<.named> property. The compiler is allowed to -stop marking "named" pairs at the first C<< <== >>, but the code that -converts unused positional arguments to implicit slurpy list needs to -be careful to clear the C<.named> property on arguments so converted. -For instance, if you say +Because named and positional arguments can be freely mixed, the +programmer always needs to disambiguate pairs literals from named +arguments with parenthesis: +# Named argument "a" push @array, 1, 2, :a; -the compiler cannot know that the slurpy list starts at 1, so it markes -:a as a named pair. But that mark needs to be cleared, or +# Pair object (a=>'b') +push @array, 1, 2, (:a); + +Perl 6 allows multiple same-named arguments, and records the relative +order of arguments with the same name. When there are more than one +argument, the C<@> sigil in the parameter list causes the arguments +to be concatenated: -say pop(@array); +sub fun (Int @x) { ... } +fun( x => 1, x => 2 ); # @x := (1, 2) -will then think you said: +Other sigils binds only to the I argument with that name: -say *pop(@array); +sub fun (Int $x) { ... } +f( x => 1, x => 2 );# $x := 2 -and treat :a as a named argument to print, which is not what you want. +This means a defaults must come I known named parameters, +similar to how hash constructors work: -In any event, the named parameters need to be kept in the list until -bound. An implementation that pulls named parameters out of the list -into a hash prematurely will lose the ordering of the push above, -for instance. +# Allow "x" and "y" in %defaults be overrided +f( *%defaults, x => 1, y => 2 ); =head2 Invocant parameters
[svn:perl6-synopsis] r8553 - doc/trunk/design/syn
Author: autrijus Date: Mon Apr 3 05:47:07 2006 New Revision: 8553 Modified: doc/trunk/design/syn/S09.pod Log: * S09: Leo pointed out the paragraph on autovivifiction is still mentioning references. Replace it with modern wording (surface semantics stays unchanged) Modified: doc/trunk/design/syn/S09.pod == --- doc/trunk/design/syn/S09.pod(original) +++ doc/trunk/design/syn/S09.podMon Apr 3 05:47:07 2006 @@ -696,9 +696,10 @@ my $val := $hash{foo}{bar}; my @array; -my $ref = \$array[0][0]; +my $ref = \$array[0][0]; # $ref is an Arguments object - see S02 my %hash; $hash{foo}{bar} = "foo"; # duh -This rule applies to dereferencing arrays, hashes, and scalar references. +This rule applies to C, C, and C container objects. +
[svn:perl6-synopsis] r8555 - doc/trunk/design/syn
Author: autrijus Date: Mon Apr 3 15:48:30 2006 New Revision: 8555 Modified: doc/trunk/design/syn/S06.pod Log: * S06: Make it clear that concat-means-concat for duplicated named arguments, and that it is possible to bind a tuple into a scalar. sub fun (Int @x) { ... } fun( x => (1, 2), x => (3, 4) );# @x := (1, 2, 3, 4) sub fun (Int $x) { ... } fun( x => (1, 2), x => (3, 4) );# $x := (3, 4) Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podMon Apr 3 15:48:30 2006 @@ -423,15 +423,17 @@ to be concatenated: sub fun (Int @x) { ... } -fun( x => 1, x => 2 ); # @x := (1, 2) +fun( x => 1, x => 2 ); # @x := (1, 2) +fun( x => (1, 2), x => (3, 4) );# @x := (1, 2, 3, 4) Other sigils binds only to the I argument with that name: sub fun (Int $x) { ... } -f( x => 1, x => 2 );# $x := 2 +f( x => 1, x => 2 );# $x := 2 +fun( x => (1, 2), x => (3, 4) );# $x := (3, 4) -This means a defaults must come I known named parameters, -similar to how hash constructors work: +This means a hash holding default values must come I known named +parameters, similar to how hash constructors work: # Allow "x" and "y" in %defaults be overrided f( *%defaults, x => 1, y => 2 );
[svn:perl6-synopsis] r8567 - doc/trunk/design/syn
Author: autrijus Date: Wed Apr 5 18:36:02 2006 New Revision: 8567 Modified: doc/trunk/design/syn/S03.pod Log: * Prefix sigil casters $ @ % & now joins the other prefix unary operators, such as \ ~ + *, on the 4th level of precedence table. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podWed Apr 5 18:36:02 2006 @@ -14,7 +14,7 @@ Date: 8 Mar 2004 Last Modified: 5 Apr 2006 Number: 3 - Version: 16 + Version: 17 =head1 Operator renaming @@ -546,7 +546,7 @@ method postfix . .+ .? .* .() .[] .{} .«» .= autoincrement ++ -- exponentiation ** -symbolic unary ! + - ~ ? * ** +^ ~^ ?^ \ ^ +symbolic unary ! + - ~ ? $ @ % & * ** +^ ~^ ?^ \ ^ multiplicative * / % x xx +& +< +> ~& ~< ~> additive+ - ~ +| +^ ~| ~^ junctive and (all) &
[svn:perl6-synopsis] r8568 - doc/trunk/design/syn
Author: autrijus Date: Wed Apr 5 18:59:00 2006 New Revision: 8568 Modified: doc/trunk/design/syn/S03.pod Log: * S03: Excise the "reference" word; "array reference" is now simply Array objects, and prefix * can flatten hashes as well as arrays. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podWed Apr 5 18:59:00 2006 @@ -55,13 +55,13 @@ For those still living without the blessings of Unicode, that can also be written: C<<< << ... >> >>>. -=item * The scalar comma C<,> now constructs a List reference of its +=item * The scalar comma C<,> now constructs a List object from its operands. You have to use a C<[-1]> subscript to get the last one. -=item * The backslash operator still produces a reference, but when -applied to a parenthesized list, produces a List object (an arglist) -instead of a list of refs. (According to the previous item, in scalar -context the backslash is redundant, but is good documentation anyway.) +=item * The backslash operator captures its arguments, and returns an +object representing those arguments. You can I this object +in several ways to retrieve different parts of the arguments; see the +definition of C S02 for details. =item * The old scalar C<..> flipflop operator is now done with C operator. (C<..> now always produces a Range object @@ -189,7 +189,7 @@ Note that method calls are really postfix operators, not infix, so you shouldn't put a C<«> after the dot. -Hyper operators are defined recursively on array references, so: +Hyper operators are defined recursively on arrays, so: -« [[1, 2], 3] #[-«[1, 2], -«3] # == [[-1, -2], -3] @@ -390,15 +390,17 @@ are bound to the same underlying variable. C<$x =:= $y> would return true in the above example. -=head1 List flattening +=head1 Flattening Since typeglobs are being removed, unary C<*> may now serve as a -lazy list flattening operator. It is used to "flatten" an Array -(or List) into the List being constructed for the current call, -usually to allow the array's contents to be used as the arguments of -a subroutine call. Note that those arguments still must comply with -the subroutine's signature, but the presence of C<*> defers that test -until run time for that argument (and for any subsequent arguments): +general-purpose flattening operator. It can be used to "flatten" an +Array or Hash into the current call's argument list (as positional +and named arguments respectively), usually to allow their contents to be used +as the arguments of a subroutine call. + +Note that those arguments still must comply with the subroutine's +signature, but the presence of C<*> defers that test until run time for +that argument (and for any subsequent arguments): my @args = ([EMAIL PROTECTED], @bar); push [EMAIL PROTECTED]; @@ -409,26 +411,24 @@ as is this: -my $args = \(@foo, @bar);# construct List object +my $args = \(@foo, @bar);# construct Arguments object push *$args; -In list context, a scalar reference to an array does not flatten. Hence +In list context, a Scalar holding an Array object does not flatten. Hence $bar = @bar; push @foo, $bar; -merely pushes a single scalar reference onto C<@foo>. You can -explicitly flatten it in any of these ways: +merely pushes a single Array object onto C<@foo>. You can explicitly flatten +it in any of these ways: push @foo, *$bar; push @foo, @$bar; push @foo, $bar[]; -(The C<*> in list context doesn't change the call semantics as it -does in scalar context.) Note that these three forms also allow you -to specify list context on assignment: +Note that the last two forms also allow you to specify list context on +assignment: -*$bar = (1,2,3); @$bar = (1,2,3); $bar[] = (1,2,3);
[svn:perl6-synopsis] r8569 - doc/trunk/design/syn
Author: autrijus Date: Wed Apr 5 19:08:28 2006 New Revision: 8569 Modified: doc/trunk/design/syn/S02.pod doc/trunk/design/syn/S05.pod Log: * S02/S05: Excise "reference" from them. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podWed Apr 5 19:08:28 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 10 Aug 2004 - Last Modified: 1 Apr 2006 + Last Modified: 6 Apr 2006 Number: 2 - Version: 19 + Version: 20 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -326,13 +326,13 @@ Sigils are now invariant. C<$> always means a scalar variable, C<@> an array variable, and C<%> a hash variable, even when subscripting. -Array and hash variable names in scalar context automatically produce -references. +Variables such as C<@array> and C<%hash> in scalar context simply +returns themselves Array and Hash objects. =item * -In string contexts container references automatically dereference -to appropriate (white-space separated) string values. In numeric +In string contexts, container objects automatically stringify to +appropriate (white-space separated) string values. In numeric contexts, the number of elements in the container is returned. In boolean contexts, a true value is returned if and only if there are any elements in the container. @@ -354,7 +354,7 @@ =item * -Subscripts now consistently dereference the reference produced by +Subscripts now consistently dereference the container produced by whatever was to their left. Whitespace is not allowed between a variable name and its subscript. However, there is a corresponding B form of each subscript (C<@foo.[1]> and C<%bar.{'a'}>) which @@ -380,9 +380,9 @@ There is a need to distinguish list assignment from list binding. List assignment works exactly as it does in Perl 5, copying the values. There's a new C<:=> binding operator that lets you bind -names to array and hash references without copying, just as subroutine -arguments are bound to formal parameters. See S06 for more about -parameter binding. +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. =item * @@ -442,12 +442,11 @@ =item * -Unlike in Perl 5, the notation C<&foo> merely creates a reference -to function "C" without calling it. Any function reference may -be dereferenced and called using parens (which may, of course, -contain arguments). Whitespace is not allowed before the parens, -but there is a corresponding C<.()> operator, which allows you to -insert optional whitespace before the dot. +Unlike in Perl 5, the notation C<&foo> merely returns the C +function as a Code object without calling it. You may call any Code +object parens (which may, of course, contain arguments). Whitespace +is not allowed before the parens, but there is a corresponding C<.()> +operator, which allows you to insert optional whitespace before the dot. =item * @@ -457,7 +456,7 @@ &foo:(Int,Num) -It still just returns a function reference. A call may also be partially +It still just returns a C object. A call may also be partially applied by using an argument list literal as a postfix operator: &foo\(1,2,3,:mice) @@ -496,12 +495,11 @@ =item * -A hash reference in numeric context returns the number of pairs -contained in the hash. A hash reference in a boolean context returns -true if there are any pairs in the hash. In either case, any intrinsic -iterator would be reset. (If hashes do carry an intrinsic iterator -(as they do in Perl 5), there will be a C<.reset> method on the hash -object to reset the iterator explicitly.) +In numeric context, a Hash object returns the number of pairs contained +in the hash. Hash in a boolean context returns true if there are any pairs +in the hash. In either case, any intrinsic iterator would be reset. (If +hashes do carry an intrinsic iterator (as they do in Perl 5), there will +be a C<.reset> method on the hash object to reset the iterator explicitly.) =item * @@ -647,7 +645,7 @@ =item * -The current lexical symbol table may now be referenced through the +The current lexical symbol table is now accessible through the pseudo-package C. The current package symbol table is visible as pseudo-package C. The C name refers to the C symbol table immediately surrounding the current C, and C is the one @@ -1400,12 +1398,12 @@ numeric num Num + string str Str ~ -There are also various reference contexts that require particular kinds of -
[svn:perl6-synopsis] r8570 - doc/trunk/design/syn
Author: autrijus Date: Wed Apr 5 19:18:40 2006 New Revision: 8570 Modified: doc/trunk/design/syn/S04.pod doc/trunk/design/syn/S06.pod doc/trunk/design/syn/S09.pod doc/trunk/design/syn/S10.pod doc/trunk/design/syn/S12.pod Log: * S04/S06/S09/S10/S12: Excise "reference" from them. Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podWed Apr 5 19:18:40 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 19 Aug 2004 - Last Modified: 1 Apr 2006 + Last Modified: 6 Apr 2006 Number: 4 - Version: 12 + Version: 13 This document summarizes Apocalypse 4, which covers the block and statement syntax of Perl. @@ -400,8 +400,8 @@ 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 -and bare closures are transparent to C. If you pass a reference -to a closure outside of its official "sub" scope, it is illegal to +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 or by falling off the end of it. @@ -828,9 +828,9 @@ so that if you ever use the current reference to the routine, it gets the current snapshot of its world, lexically speaking. -Some closures produce references at compile time that cannot be +Some closures produce C objects at compile time that cannot be cloned, because they're not attached to any runtime code that can -actively clone them. C, C, C, and C blocks probably +actively clone them. C, C, C, and C blocks fall into this category. Therefore you can't reliably refer to run-time variables from them even if they appear to be in scope. (The compile-time closure may, in fact, see a some kind of permanent Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podWed Apr 5 19:18:40 2006 @@ -13,9 +13,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 21 Mar 2003 - Last Modified: 1 Apr 2006 + Last Modified: 6 Apr 2006 Number: 6 - Version: 22 + Version: 23 This document summarizes Apocalypse 6, which covers subroutines and the @@ -119,11 +119,11 @@ Raw blocks are also executable code structures in Perl 6. -Every block defines an object of type C, which may either be executed -immediately or passed on as a C reference argument. A +Every block defines an object of type C, which may either be +executed immediately or passed on as a C object. A bare block where an operator is expected is bound to the current statement level control syntax. A bare block where a term is expected -merely produces a reference. If the term bare block occurs in a list, +merely produces a C object. If the term bare block occurs in a list, it is considered the final element of that list unless followed immediately by a comma or comma surrogate. @@ -399,7 +399,7 @@ doit %hash{'b'}:p,1,2,3; instead.. (The C<:p> stands for "pairs", not "positional"--the -C<:p> adverb may be placed on any hash reference to make it mean +C<:p> adverb may be placed on any Hash objects to make it mean "pairs" instead of "values".) Pair constructors are recognized syntactically at the call level and @@ -1821,7 +1821,7 @@ } # Old values of $*foo and &bar reinstated at this point C invokes its argument's C<.TEMP> method. The method is expected -to return a reference to a subroutine that can later restore the current +to return a C object that can later restore the current value of the object. At the end of the lexical scope in which the C was applied, the subroutine returned by the C<.TEMP> method is executed. @@ -1979,7 +1979,7 @@ &textfrom := &substr.assuming:str($text):len(Inf); -It returns a reference to a subroutine that implements the same behaviour +It returns a C object that implements the same behaviour as the original subroutine, but has the values passed to C<.assuming> already bound to the corresponding parameters: @@ -2150,7 +2150,7 @@ C<{...}> is always a block. However, if it is completely empty or consists of a single list, the first element of which is either a hash -or a pair, it is executed immediately to compose a hash reference. +or a pair, it is executed immediately to compose a Hash object. The standard C list operator is equivalent to: Modified: doc/trunk/design/syn/S09.pod == --- doc/trunk/desi
[svn:perl6-synopsis] r8571 - doc/trunk/design/syn
Author: autrijus Date: Wed Apr 5 21:20:13 2006 New Revision: 8571 Modified: doc/trunk/design/syn/S02.pod Log: * Damian noted that the S02 chunk about Code object doesn't quite make sense anymore; fixed the grammar and supplied two examples. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podWed Apr 5 21:20:13 2006 @@ -444,9 +444,14 @@ Unlike in Perl 5, the notation C<&foo> merely returns the C function as a Code object without calling it. You may call any Code -object parens (which may, of course, contain arguments). Whitespace -is not allowed before the parens, but there is a corresponding C<.()> -operator, which allows you to insert optional whitespace before the dot. +object with parens after it (which may, of course, contain arguments): + +&foo($arg1, $arg2); + +Whitespace is not allowed before the parens, but there is a corresponding +C<.()> operator, which allows you to insert optional whitespace before the dot: + +&foo.($arg1, $arg2); =item *
[svn:perl6-synopsis] r8572 - doc/trunk/design/syn
Author: autrijus Date: Wed Apr 5 22:15:15 2006 New Revision: 8572 Modified: doc/trunk/design/syn/S02.pod Log: * S02: Grammar fixes from Uri. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podWed Apr 5 22:15:15 2006 @@ -327,7 +327,7 @@ Sigils are now invariant. C<$> always means a scalar variable, C<@> an array variable, and C<%> a hash variable, even when subscripting. Variables such as C<@array> and C<%hash> in scalar context simply -returns themselves Array and Hash objects. +return themselves as C and C objects. =item * @@ -442,7 +442,7 @@ =item * -Unlike in Perl 5, the notation C<&foo> merely returns the C +Unlike in Perl 5, the notation C<&foo> merely stands for the C function as a Code object without calling it. You may call any Code object with parens after it (which may, of course, contain arguments): @@ -500,11 +500,12 @@ =item * -In numeric context, a Hash object returns the number of pairs contained -in the hash. Hash in a boolean context returns true if there are any pairs -in the hash. In either case, any intrinsic iterator would be reset. (If -hashes do carry an intrinsic iterator (as they do in Perl 5), there will -be a C<.reset> method on the hash object to reset the iterator explicitly.) +In numeric context (i.e. when casted into C or C), a Hash 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 +iterator (as they do in Perl 5), there will be a C<.reset> method on the h +hash object to reset the iterator explicitly.) =item *
[svn:perl6-synopsis] r8573 - doc/trunk/design/syn
Author: autrijus Date: Wed Apr 5 22:30:44 2006 New Revision: 8573 Modified: doc/trunk/design/syn/S02.pod Log: * S02: fix the three places where the old form: $x .(...) needs to be replaced to the new form: $x. (...) Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podWed Apr 5 22:30:44 2006 @@ -358,7 +358,7 @@ whatever was to their left. Whitespace is not allowed between a variable name and its subscript. However, there is a corresponding B form of each subscript (C<@foo.[1]> and C<%bar.{'a'}>) which -allows optional whitespace before the dot (except when interpolating). +allows optional whitespace after the dot (except when interpolating). Constant string subscripts may be placed in angles, so C<%bar.{'a'}> may also be written as C<< %bar >> or C<< %bar. >>. @@ -449,9 +449,9 @@ &foo($arg1, $arg2); Whitespace is not allowed before the parens, but there is a corresponding -C<.()> operator, which allows you to insert optional whitespace before the dot: +C<.()> operator, which allows you to insert optional whitespace after the dot: -&foo.($arg1, $arg2); +&foo. ($arg1, $arg2); =item * @@ -1316,15 +1316,15 @@ pairs. To align values of option pairs, you may not use the dot postfix forms: -:longkey .($value) -:shortkey . -:fookey .{ $^a <=> $^b } +:longkey. ($value) +:shortkey. +:fookey. { $^a <=> $^b } These will be interpreted as -:longkey(1) .($value) -:shortkey(1) . -:fookey(1) .{ $^a <=> $^b } +:longkey(1). ($value) +:shortkey(1). +:fookey(1). { $^a <=> $^b } You just have to put spaces inside the parenthesis form to align things.
[svn:perl6-synopsis] r8574 - doc/trunk/design/syn
Author: autrijus Date: Wed Apr 5 22:38:07 2006 New Revision: 8574 Modified: doc/trunk/design/syn/S02.pod Log: * S02: use sane (and valid) examples for rule_mod_internal and rule_mod_external grammatical categories. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podWed Apr 5 22:38:07 2006 @@ -1614,8 +1614,8 @@ rule_metachar:<,> /,/ rule_backslash: /\w/ and /\W/ rule_assertion:<*> /<*stuff>/ -rule_mod_internal: m:p5// -rule_mod_external: m:p5// +rule_mod_internal: m:/ ... :perl5 ... / +rule_mod_external: m:nth(3)/ ... / trait_verb:has $.tail handles trait_auxiliary: my $x shall conform scope_declarator: has $.x;
[svn:perl6-synopsis] r8593 - doc/trunk/design/syn
Author: autrijus Date: Thu Apr 6 01:12:52 2006 New Revision: 8593 Modified: doc/trunk/design/syn/S02.pod doc/trunk/design/syn/S13.pod Log: * S02/S13: s/casted/cast/, as suggested by Uri. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podThu Apr 6 01:12:52 2006 @@ -500,11 +500,11 @@ =item * -In numeric context (i.e. when casted into C or C), a Hash object +In numeric context (i.e. when cast into C or C), a Hash 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 -iterator (as they do in Perl 5), there will be a C<.reset> method on the h +iterator (as they do in Perl 5), there will be a C<.reset> method on the hash object to reset the iterator explicitly.) =item * Modified: doc/trunk/design/syn/S13.pod == --- doc/trunk/design/syn/S13.pod(original) +++ doc/trunk/design/syn/S13.podThu Apr 6 01:12:52 2006 @@ -120,7 +120,7 @@ =head1 Type Casting A class can use the C<< *infix: >> submethod to declare that its objects -can be casted to some other class: +can be cast to some other class: multi submethod *infix: (IO) { $*OUT } multi submethod *infix: (Int) { 1 }
[svn:perl6-synopsis] r8594 - doc/trunk/design/syn
Author: autrijus Date: Thu Apr 6 01:29:34 2006 New Revision: 8594 Modified: doc/trunk/design/syn/S03.pod Log: * More grammar nits, from Daniel Hulme Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podThu Apr 6 01:29:34 2006 @@ -219,10 +219,10 @@ If fewer than two arguments are given, one MMD attempt is made to dispatch to the operator anyway with whatever arguments are given. -If this MMD dispatch succeeds, the result becomes the result of the -of the reduce. +If this multi-dispatch succeeds, the result becomes the result of the +reduce. -Otherwise, if the MMD dispatch fails, then if there is one argument, +Otherwise, if the dispatch fails, then if there is one argument, that argument is returned. However, this default doesn't make sense for an operator like C<< < >> that doesn't return the same type as it takes, so these kinds of operators overload the single-argument case
[svn:perl6-synopsis] r8698 - doc/trunk/design/syn
Author: autrijus Date: Sat Apr 15 06:17:49 2006 New Revision: 8698 Modified: doc/trunk/design/syn/S02.pod doc/trunk/design/syn/S03.pod doc/trunk/design/syn/S06.pod doc/trunk/design/syn/S09.pod Log: * Synopses: Change "Arguments" to "Capture" to avoid using a plural word as a class name. (Also it makes it easier later to say that "Match" is a subclass of "Capture".) Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podSat Apr 15 06:17:49 2006 @@ -525,35 +525,33 @@ =item * -An argument list object (C) may be created with backslashed parens: +An argument list object (C) may be created with backslashed parens: $args = \(1,2,3,:mice) -Values in C values are parsed as ordinary expressions, marked as -positional, named, to-be-flattened, and so on. +Values in C are parsed as ordinary expressions, marked as invocant, +positional, named, and so on. -Like C objects, C are immutable in the abstract, but -evaluates its arguments lazily. Before everything inside a C are +Like C objects, C objects are immutable in the abstract, but +evaluates its arguments lazily. Before everything inside a C are fully evaluated (which happens at compile time when all the arguments are constants), the eventual value may well be unknown. All we know is that 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 pipes 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. -You may cast C to other types with a prefix sigil operator: +You may retrieve parts from a C object with a prefix sigil operator: $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 Code" or "Code($args)" When cast into an array, you can access all the positional arguments; into a -hash, all named arguments; into a scalar, the invocant; into code, its slurpy -nameless block. +hash, all named arguments; into a scalar, its invocant. All prefix sigil operators accept one positional argument, evaluated in scalar context as a rvalue. They can interpolate in strings if called with Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podSat Apr 15 06:17:49 2006 @@ -61,7 +61,7 @@ =item * The backslash operator captures its arguments, and returns an object representing those arguments. You can I this object in several ways to retrieve different parts of the arguments; see the -definition of C S02 for details. +definition of C in S02 for details. =item * The old scalar C<..> flipflop operator is now done with C operator. (C<..> now always produces a Range object @@ -456,7 +456,7 @@ as is this: -my $args = \(@foo, @bar);# construct Arguments object +my $args = \(@foo, @bar);# construct a Capture object push *$args; In list context, a Scalar holding an Array object does not flatten. Hence Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podSat Apr 15 06:17:49 2006 @@ -403,7 +403,7 @@ "pairs" instead of "values".) Pair constructors are recognized syntactically at the call level and -put into the named slot of the C structure. Hence they may be +put into the named slot of the C structure. Hence they may be bound to positionals only by name, not as ordinary positional C objects. Leftover named arguments can be slurped into a slurpy hash. @@ -579,7 +579,7 @@ so that you can use more descriptive internal parameter names without imposing inconveniently long external labels on named arguments. -Arguments that correspond to named parameters are evaluated in scalar +Capture that correspond to named parameters are evaluated in scalar context. They can only be passed by name, so it doesn't matter what order you pass them in, so long as they don't intermingle with any positional arguments: @@ -681,13 +681,13 @@ =head2 Argument list binding -The underlying C object may be bound to a single scalar +The underlying C object may be bound to a single scalar parame
[svn:perl6-synopsis] r8724 - doc/trunk/design/syn
Author: autrijus Date: Sun Apr 16 18:24:04 2006 New Revision: 8724 Modified: doc/trunk/design/syn/S06.pod doc/trunk/design/syn/S09.pod Log: * more typo cleanups promted by Dr. Ruud. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podSun Apr 16 18:24:04 2006 @@ -705,7 +705,7 @@ =head2 Flattening argument lists -The unary prefix operator C<*> casts a value to an C +The unary prefix operator C<*> casts a value to a C object, then splices it into the argument list it occurs in. Casting C to C is a no-op: Modified: doc/trunk/design/syn/S09.pod == --- doc/trunk/design/syn/S09.pod(original) +++ doc/trunk/design/syn/S09.podSun Apr 16 18:24:04 2006 @@ -697,7 +697,7 @@ my $val := %hash; my @array; -my $ref = [EMAIL PROTECTED]; # $ref is an Capture object - see S02 +my $ref = [EMAIL PROTECTED]; # $ref is a Capture object - see S02 my %hash; %hash = "foo"; # duh
[svn:perl6-synopsis] r8741 - doc/trunk/design/syn
Author: autrijus Date: Mon Apr 17 08:52:55 2006 New Revision: 8741 Modified: doc/trunk/design/syn/S04.pod Log: * S04: Capture ~~ Signature can test for bindableness. Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podMon Apr 17 08:52:55 2006 @@ -764,6 +764,7 @@ Array .[number] array element truth* match if $_[number] 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 $_) Any Class class membership match if $_.does($x) Any Role role playing match if $_.does($x)
[svn:perl6-synopsis] r8765 - doc/trunk/design/syn
Author: autrijus Date: Mon Apr 17 20:39:37 2006 New Revision: 8765 Modified: doc/trunk/design/syn/S06.pod Log: * S06: Clarified "multidimensional Capture" part by stating that only the positional/named parts gets into *@;x, and the invocant is exempt from it. This allows for method calls that takes multiple slices, such as $moose.zip(1;2;3) in addition to zip(1;2;3). Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podMon Apr 17 20:39:37 2006 @@ -13,9 +13,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 21 Mar 2003 - Last Modified: 15 Apr 2006 + Last Modified: 18 Apr 2006 Number: 6 - Version: 24 + Version: 25 This document summarizes Apocalypse 6, which covers subroutines and the @@ -744,11 +744,11 @@ =head2 Multidimensional argument list binding -Some functions take more than one C as their argument list, that they -wish not to be flattened into one list. For instance, C wants to -iterate several lists in parallel, while array and hash subscripts want to -process multidimensional slices. The set of underlying argument list (Capture) -objects may be bound to a single array parameter declared with a C<;> twigil: +Some functions take more than one lists of positional and/or named arguments, +that they wish not to be flattened into one list. For instance, C wants +to iterate several lists in parallel, while array and hash subscripts want to +process multidimensional slices. The set of underlying argument lists may be +bound to a single array parameter declared with a C<;> twigil: sub foo (*@;slices) { ... } @@ -768,6 +768,11 @@ sub foo (*@;slices --> Num) { ... } +The invocant does not participate in multi-dimensional argument lists, +so C is not present in any of the C<@;slices> below: + +method foo (*@;slices) { ... } + =head2 Zero-dimensional argument list If you call a function without parens and supply no arguments, the
[svn:perl6-synopsis] r8877 - doc/trunk/design/syn
Author: autrijus Date: Wed Apr 19 06:01:46 2006 New Revision: 8877 Modified: doc/trunk/design/syn/S06.pod Log: * S06: two trivial syntax typos. Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podWed Apr 19 06:01:46 2006 @@ -779,7 +779,7 @@ argument list becomes a zero-dimensional slice. It differs from C<\()> in several ways: -sub foo (@;slices) {...} +sub foo (*@;slices) {...} foo;# +@;slices == 0 foo(); # +@;slices == 1 @@ -1188,9 +1188,9 @@ to indicate a signature. Otherwise you must at least put the sigil of the variable, or we can't correctly differentiate: -my Dog ($fido, $spot) = twodogs(); # list of two dogs +my Dog ($fido, $spot) := twodogs(); # list of two dogs my Dog $ ($fido, $spot) := twodogs(); # one twodog object -my Dog :($fido, $spot) := twodogs(); # one twodog object +my Dog :($fido, $spot) := twodogs(); # one twodog object Subsignatures can be matched directly with rules by using C<:(...)> notation.
[svn:perl6-synopsis] r8893 - doc/trunk/design/syn
Author: autrijus Date: Thu Apr 20 23:49:15 2006 New Revision: 8893 Modified: doc/trunk/design/syn/S05.pod Log: Stylistic cleanup of S05; no functional changes. * s/TimToady/Larry Wall/ * Consistently change "foo" to C or I to be consistent with context. * Fixed the "state $x ||= /.../" example, which will cause rematch on matchfail. "state $x //= /.../" would be the correct form. * Clarified that only Int or Range objects can sensibly be used as quantifier range; matching something "3.5+6i" times wouldn't quite make sense. Modified: doc/trunk/design/syn/S05.pod == --- doc/trunk/design/syn/S05.pod(original) +++ doc/trunk/design/syn/S05.podThu Apr 20 23:49:15 2006 @@ -11,16 +11,17 @@ =head1 VERSION - Maintainer: Patrick Michaud <[EMAIL PROTECTED]> (& TimToady) + Maintainer: Patrick Michaud <[EMAIL PROTECTED]> and + Larry Wall <[EMAIL PROTECTED]> Date: 24 Jun 2002 Last Modified: 20 Apr 2006 Number: 5 - Version: 17 + Version: 18 This document summarizes Apocalypse 5, which is about the new regex -syntax. We now try to call them "regex" because they haven't been +syntax. We now try to call them I because they haven't been regular expressions for a long time. When referring to their use in -a grammar, the term "rule" is preferred. +a grammar, the term I is preferred. =head1 New match state and capture variables @@ -126,7 +127,7 @@ Since this is implicitly anchored to the position, it's suitable for building parsers and lexers. The pattern you supply to a Perl macro's -"is parsed" trait has an implicit C<:p> modifier. +C trait has an implicit C<:p> modifier. Note that @@ -266,7 +267,7 @@ =item * -The new C<:rw> modifier causes this regex to "claim" the current +The new C<:rw> modifier causes this regex to I the current string for modification rather than assuming copy-on-write semantics. All the bindings in C<$/> become lvalues into the string, such that if you modify, say, C<$1>, the original string is modified in @@ -394,8 +395,8 @@ =item * -C<.> matches an "anything", while C<\N> matches an "anything except -newline". (The C modifier is gone.) In particular, C<\N> matches +C<.> matches an I, while C<\N> matches an I. (The C modifier is gone.) In particular, C<\N> matches neither carriage return nor line feed. =item * @@ -451,7 +452,7 @@ The repetition specifier is now C<**{...}> for maximal matching, with a corresponding C<**{...}?> for minimal matching. Space is allowed on either side of the asterisks. The curlies are taken to -be a closure returning a number or a range. +be a closure returning an Int or a Range object. / value was (\d ** {1..6}?) with ([\w]**{$m..$n}) / @@ -459,7 +460,7 @@ / [foo]**{1,3} / -(At least, it fails in the absence of "C", +(At least, it fails in the absence of C, which is likely to be unimplemented in Perl 6.0.0 anyway). The optimizer will likely optimize away things like C<**{1...}> @@ -471,7 +472,7 @@ =item * -C<< <...> >> are now extensible metasyntax delimiters or "assertions" +C<< <...> >> are now extensible metasyntax delimiters or I (i.e. they replace Perl 5's crufty C<(?...)> syntax). =back @@ -486,7 +487,7 @@ =item * -Instead they're passed "raw" to the regex engine, which can then decide +Instead they're passed I to the regex engine, which can then decide how to handle them (more on that below). =item * @@ -520,7 +521,7 @@ As with a scalar variable, each element is matched as a literal unless it happens to be a Regex object, in which case it is matched as a subrule. As with scalar subrules, a tainted subrule always fails. -All values pay attention to the current C<:ignorecase> setting +All values pay attention to the current C<:ignorecase> setting. =item * @@ -539,7 +540,7 @@ If the value is a string, it is matched literally, starting after where the key left off matching. As a natural consequence, if the value is -"", nothing special happens except that the key match succeeds. +C<"">, nothing special happens except that the key match succeeds. =item * @@ -669,7 +670,7 @@ internally that turns into a hash lookup.) As with bare hash, the longest key matches according to the venerable -"longest token rule", but in addition, you may combine multiple hashes +I, but in addition, you may combine multiple hashes under the same longest-token consideration like this: <%statement|%prefix|%term> @@ -761,10 +762,10 @@ / \d+ / -except
[svn:perl6-synopsis] r8899 - doc/trunk/design/syn
Author: autrijus Date: Fri Apr 21 08:56:22 2006 New Revision: 8899 Modified: doc/trunk/design/syn/S05.pod Log: * S05: Oops, turns out I entirely read perlop.pod incorrectly; "it matches once only" means "it matches successfully once only", not "it performs the match once only". Sorry, TimToady++'s original example of: (state $x) ||= / pattern /; was correct. Modified: doc/trunk/design/syn/S05.pod == --- doc/trunk/design/syn/S05.pod(original) +++ doc/trunk/design/syn/S05.podFri Apr 21 08:56:22 2006 @@ -1066,9 +1066,9 @@ The Perl 5 C syntax (I) was rarely used and can be now emulated more cleanly with a state variable: -(state $x) //= / pattern /;# only matches first time +(state $x) ||= / pattern /;# only matches first time -To reset the pattern, simply say C. +To reset the pattern, simply say C<$x = 0>. =back
[svn:perl6-synopsis] r8908 - doc/trunk/design/syn
Author: autrijus Date: Sat Apr 22 00:22:21 2006 New Revision: 8908 Modified: doc/trunk/design/syn/S03.pod Log: * S03: Document that C and C forms are not declarators. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podSat Apr 22 00:22:21 2006 @@ -535,6 +535,10 @@ a function, except that, unlike in a function call, the parameters are bound C by default rather than C. See Binding below. +Note that C and C are I variable declarators, because +their effects only take place at runtime. Therefore, they take an ordinary +lvalue object as their arguments. See S04 for more details. + There are a number of other declarators that are not variable declarators. These include both type declarators:
[svn:perl6-synopsis] r8909 - doc/trunk/design/syn
Author: autrijus Date: Sat Apr 22 03:04:09 2006 New Revision: 8909 Modified: doc/trunk/design/syn/S03.pod Log: * S03: Clarify that C<*> does not really provide list context to its operand; rather, it injects the operand to the currnent argument. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podSat Apr 22 03:04:09 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 8 Mar 2004 - Last Modified: 21 Apr 2006 + Last Modified: 22 Apr 2006 Number: 3 - Version: 19 + Version: 20 =head1 Changes to existing operators @@ -28,12 +28,13 @@ =item * The string concatenation C<.> becomes C<~>. Think of it as "stitching" the two ends of its arguments together. -=item * Unary C<~> now imposes a string context on its argument, and -C<+> imposes a numeric context (as opposed to being a no-op in Perl 5). -Along the same lines, C imposes a boolean context, and C<*> imposes -a list context. Unary sigils impose the container context implied -by their sigil. As with Perl 5, however, C<$$foo[bar]> parses as -C<$($foo)[bar]>, so you need C<$($foo[bar])> to mean the other way. +=item * Unary C<~> now imposes a string (C) context on its argument, and +C<+> imposes a numeric (C) context (as opposed to being a no-op in Perl +5). Along the same lines, C imposes a boolean (C) context, and C<*> +imposes an function-arguments (C) context. Unary sigils impose the +container context implied by their sigil. As with Perl 5, however, +C<$$foo[bar]> parses as C<$($foo)[bar]>, so you need C<$($foo[bar])> to mean +the other way. =item * Bitwise operators get a data type prefix: C<+>, C<~>, or C. For example, C<|> becomes either C<+|> or C<~|> or C, depending on @@ -561,19 +562,20 @@ These all have their uses and are explained in subsequent synopses. -=head1 Flattening +=head1 Argument List Interpolating -Since typeglobs are being removed, unary C<*> may now serve as a -general-purpose flattening operator. It can be used to "flatten" an -Array or Hash into the current call's argument list (as positional -and named arguments respectively), usually to allow their contents to be used -as the arguments of a subroutine call. +Since typeglobs are being removed, unary C<*> may now serve as an +interpolator, by casting its single operand to a C object +and insert it into the current argument list. + +It can be used to interpolate an C or C into the current +call, as positional and named arguments respectively. Note that those arguments still must comply with the subroutine's signature, but the presence of C<*> defers that test until run time for that argument (and for any subsequent arguments): -my @args = ([EMAIL PROTECTED], @bar); +my @args = (scalar @foo, @bar); push [EMAIL PROTECTED]; is equivalent to: @@ -597,6 +599,11 @@ push @foo, @$bar; push @foo, $bar[]; +The first form works by interpolating C<$bar>'s elements into positional +arguments to C. The last two forms works because the slurpy +array in C's signature flattens the C object in positional +argument. + Note that the last two forms also allow you to specify list context on assignment: @@ -614,9 +621,13 @@ not to mention the C<< <> >>, C<< .<> >>, C<«»>, and C<.«»> constant and interpolating slice subscripting forms. -The C<*> operator flattens lazily. To get an immediate flattening like -Perl 5 does, use unary C<**> instead. You may use either of them on -a scalar iterator to force it to iterate. +The C<*> operator interpolates lazily for C and C objects. +To get an immediate interpolation like Perl 5 does, use unary C<**> instead: + +func(*(1..Inf));# works fine +func(**(1..Inf)); # never terminates + +You may use either of them on a scalar iterator to force it to iterate. =head1 Piping operators
[svn:perl6-synopsis] r8917 - doc/trunk/design/syn
Author: autrijus Date: Sun Apr 23 08:02:50 2006 New Revision: 8917 Modified: doc/trunk/design/syn/S02.pod Log: * S02: The *() form now means *($/). * Clarified that $() etc are term-level macros. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podSun Apr 23 08:02:50 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 10 Aug 2004 - Last Modified: 22 Apr 2006 + Last Modified: 23 Apr 2006 Number: 2 - Version: 29 + Version: 30 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -603,8 +603,9 @@ All prefix sigil operators accept one positional argument, evaluated in scalar context as a rvalue. They can interpolate in strings if called with -parentheses. The C<$()>, C<@()> and C<%()> forms defaults to C<$/> as the -implicit argument. +parentheses. The special syntax form C<$()> translates into C<$( $/ )> +to operate on the current match object; the same applies to C<@()>, C<%()> and +C<*()> forms. C objects fill the ecological niche of references in Perl 6. You can think of them as "fat" references, that is, references that
[svn:perl6-synopsis] r8918 - doc/trunk/design/syn
Author: autrijus Date: Sun Apr 23 09:07:38 2006 New Revision: 8918 Modified: doc/trunk/design/syn/S04.pod Log: * S04: the stop-parsing-on-bare-block rule for conditionals: if -e { say "exists" } { extra() } has also to stop parsing on pointies: if -e -> $x { say "exists" } { extra() } Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podSun Apr 23 09:07:38 2006 @@ -623,22 +623,25 @@ You can still parenthesize the expression argument for old times' sake, as long as there's a space between the closing paren and the opening brace. You I parenthesize the expression if there is -a bare block that would be misinterpreted as the statement's block. -This is regardless of whether a term or operator is expected where -the bare block occurs. (A block inside brackets, or used as as +a bare block or pointy block that would be misinterpreted as the statement's +block. This is regardless of whether a term or operator is expected where +the block occurs. (A block inside brackets, or used as as postcircumfix is fine, though.) Any block with whitespace 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() } is always parsed as if (-e) { say "exists" }; { extra() } +if (-e) -> $x { say "exists" }; { extra() } rather than if (-e { say "exists" }) { extra() } +if (-e (-> $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] r8941 - doc/trunk/design/syn
Author: autrijus Date: Tue Apr 25 08:48:59 2006 New Revision: 8941 Modified: doc/trunk/design/syn/S03.pod Log: * S03: Cleanups. * There's no "$s xxx" postfix form anymore -- write "$s xx *". * "@a === @a" is sufficient to illustrate the reference-identity point, not "[EMAIL PROTECTED] === [EMAIL PROTECTED]". (Although the latter is also true.) * Change the two occurrence of L to S0X to agree with the rest of the text and other specs. Also capitalize "Synopses". * Spell out the ASCII equivalent of infix "zip" as "Y". * Update code examples to reflect long dot. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podTue Apr 25 08:48:59 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 8 Mar 2004 - Last Modified: 22 Apr 2006 + Last Modified: 25 Apr 2006 Number: 3 - Version: 21 + Version: 22 =head1 Changes to existing operators @@ -51,8 +51,7 @@ =item * C splits into two operators: C (which concatenates repetitions of a string to produce a single string), and C (which creates a list of -repetitions of a list or scalar). Conjecture: the C "infix" operator -takes no right argument and is equivalent to C. +repetitions of a list or scalar). =item * Trinary C becomes C. It is a syntax error to use an operator in the middle that binds looser in precedence, such as C<=>. @@ -118,7 +117,7 @@ tests whether they are the same value (eg. C<1 === 1>); for two reference types, checks whether they have the same identity value. For reference types that do not define an identity, the reference itself is used (eg. it -is not true that C<[1,2] === [1,2]>, but it is true that C<[EMAIL PROTECTED] === [EMAIL PROTECTED]>). +is not true that C<[1,2] === [1,2]>, but it is true that C<@a === @a>). Any reference type may pretend to be a value type by defining a C<.id> method which returns a built-in value, i.e. an immutable object or a native value, @@ -148,7 +147,7 @@ =item * C<=~> becomes the "smart match" operator C<~~>, with a whole new set of semantics. Anywhere you used C<=~> before you now use C<~~>, but C<~~> is -much more general now. See L for details. (To catch "brainos", +much more general now. See S04 for details. (To catch "brainos", the Perl 6 parser defines an C<< infix:<=~> >> macro which always fails at compile time with a message directing the user either to use C<~~> or C<~=> instead, or to put a space between if they really wanted to assign a stringified value.) @@ -578,7 +577,7 @@ rule foo token foo -These all have their uses and are explained in subsequent synopses. +These all have their uses and are explained in subsequent Synopses. =head1 Argument List Interpolating @@ -658,8 +657,8 @@ my ($a,$b,$c) = "foo" xx *;# an arbitrary long list of "foo" if /foo/ ff * {...}# a latching flipflop @slice = @x[*;0;*];# any Int -%slice = %x{*;'foo'}; # any keys in domain of 1st dimension -%array[*] # *not* a zen slice +@slice = %x{*;'foo'}; # any keys in domain of 1st dimension +@array[*] # flattens, unlike @array[] C is an undefined prototype object derived from C. As a type it is abstract, and may not be instantiated as a defined object. @@ -703,7 +702,7 @@ <== grep { /^ \d+ $/ } <== @data; -Either form more clearly indicates the flow of data. See L for +Either form more clearly indicates the flow of data. See S06 for more of the (less-than-obvious) details on these two operators. =head1 Invocant marker @@ -729,7 +728,8 @@ print "Name: $name; Zip code: $zip\n"; } -C has an infix synonym, the Unicode operator C<¥>. +C has an infix synonym, the Unicode operator C<¥>, and its the ASCII +equivalent C. To read arrays in parallel like C but just sequence the values rather than generating tuples, use C instead of C. @@ -766,12 +766,12 @@ } while 0 < $i { $i++ } -It is, however, still possible to align accessors by explicitly using the C<.> -operator: +It is, however, still possible to align accessors by explicitly using the +I syntax: %monsters.{'cookie'} = Monster.new; - %people .{'john'} = Person .new; - %cats.{'fluffy'} = Cat.new; + %people. .{'john'} = Person.new; + %cats. .{'fluffy'} = Cat.new; =head1 Precedence
[svn:perl6-synopsis] r8942 - doc/trunk/design/syn
Author: autrijus Date: Tue Apr 25 09:03:00 2006 New Revision: 8942 Modified: doc/trunk/design/syn/S02.pod doc/trunk/design/syn/S03.pod doc/trunk/design/syn/S04.pod doc/trunk/design/syn/S06.pod Log: * S02, 03, 04, 06: Remove all occurrence of "tuple" and replace it with "Seq". A "Seq" is simply a List with no laz y parts (such as Range objects) in it: (1,2,3); # Seq Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podTue Apr 25 09:03:00 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 10 Aug 2004 - Last Modified: 24 Apr 2006 + Last Modified: 25 Apr 2006 Number: 2 - Version: 32 + Version: 33 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -627,11 +627,11 @@ :(Any Num Dog|Cat $numdog) Such a signature may be used within another signature to apply -additional type constraints. When applied to a tuple argument, the +additional type constraints. When applied to a C argument, the signature allows you to specify the types of parameters that would otherwise be untyped: -:(Any Num Dog|Cat $numdog, MySig *$a ($i,$j,$k,$mousestatus)) +:(Any Num Dog|Cat $numdog, MySig \$a ($i,$j,$k,$mousestatus)) =item * Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podTue Apr 25 09:03:00 2006 @@ -14,7 +14,7 @@ Date: 8 Mar 2004 Last Modified: 25 Apr 2006 Number: 3 - Version: 22 + Version: 23 =head1 Changes to existing operators @@ -722,7 +722,8 @@ =head1 C In order to support parallel iteration over multiple arrays, Perl 6 has -a C function that builds tuples of the elements of two or more arrays. +a C function that builds C objects from the elements of two or more +arrays. for zip(@names; @codes) -> [$name, $zip] { print "Name: $name; Zip code: $zip\n"; Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podTue Apr 25 09:03:00 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 19 Aug 2004 - Last Modified: 21 Apr 2006 + Last Modified: 25 Apr 2006 Number: 4 - Version: 17 + Version: 18 This document summarizes Apocalypse 4, which covers the block and statement syntax of Perl. @@ -226,8 +226,8 @@ for each(@a;@b) -> $a, $b { print "[$a, $b]\n" } -or use the C function to generate a list of tuples that each can be bound -to multiple arguments enclosed in square brackets: +or use the C function to generate a list of C objects that each can +be bound to multiple arguments enclosed in square brackets: for zip(@a;@b) -> [$a, $b] { print "[$a, $b]\n" } Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podTue Apr 25 09:03:00 2006 @@ -13,9 +13,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 21 Mar 2003 - Last Modified: 22 Apr 2006 + Last Modified: 25 Apr 2006 Number: 6 - Version: 30 + Version: 31 This document summarizes Apocalypse 6, which covers subroutines and the @@ -1196,7 +1196,7 @@ my ($i, $j, $k); @a ~~ rx/ <,> # match initial elem boundary - :(Int $i,Int $j,Int? $k)# match tuple with 2 or 3 ints + :(Int $i,Int $j,Int? $k)# match lists with 2 or 3 ints <,> # match final elem boundary /; say "i = $"; @@ -1209,7 +1209,7 @@ Note that unlike a sub declaration, a regex-embedded signature has no associated "returns" syntactic slot, so you have to use C<< --> >> -within the signature to specify the type of the tuple, or match as +within the signature to specify the type of the signature, or match as an arglist: :(Num, Num --> Coord) @@ -1225,7 +1225,7 @@ :(\Dog()) -that is, match a null tuple of type C. Nor is it equivalent to +that is, match a nullary function of type C. Nor is it equivalent to :(Dog) @@ -1233,11 +1233,7 @@ :(\Any(Dog)) -or - -:([Dog]) - -and match a tuple-ish item with a single value of type Dog. +and match a function taking a single value of type Dog. Note also that bare C<\(1,2,3)> is never legal in a regex since the first paren would try to match literally.
[svn:perl6-synopsis] r8943 - doc/trunk/design/syn
Author: autrijus Date: Tue Apr 25 09:37:36 2006 New Revision: 8943 Modified: doc/trunk/design/syn/S02.pod Log: * S02: Cleanup provisional-call text a bit, adding some more examples, and note that method calls are never provisional and cannot be invalidated. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podTue Apr 25 09:37:36 2006 @@ -1546,15 +1546,24 @@ for method calls is distinguished from sub calls, it is only unrecognized sub calls that must be treated specially. -You still must declare your subroutines, but an unrecognized bare -identifier is provisionally compiled as a subroutine call on that -assumption that such a declaration will occur by the end of the current -compilation unit. If it is not, the compile fails at C time. +You still must declare your subroutines, but a bareword with an unrecognized +name is provisionally compiled as a subroutine call, on that assumption that +such a declaration will occur by the end of the current compilation unit: + +foo; # provisional call if neither &foo nor ::foo is defined so far +foo(); # 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 + +If a postdeclaration is not seen, the compile fails at C time. (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 -call. This fixup is done only for provisional calls. If there +call. + +This fixup is done only for provisional calls. If there is I real predeclaration visible, it always takes precedence. In case of multiple ambiguous postdeclarations, either they must all be multis, or a compile-time error is declared and you must predeclare, @@ -1563,9 +1572,10 @@ since that's a run-time dispatch, and all multis are effectively visible at the point of the controlling C declaration. -Parsing of a provisional call is always done the same way list operators -are treated. If a postdeclaration bends the syntax to be inconsistent -with that, it is an error of the inconsistent signature variety. +Parsing of a bareword function as a provisional call is always done +the same way list operators are treated. If a postdeclaration bends +the syntax to be inconsistent with that, it is an error of the +inconsistent signature variety. If the unrecogized subname is followed by C<< postcircumfix:<( )> >>, it is compiled as a provisional function call of the parenthesized form.
[svn:perl6-synopsis] r8953 - doc/trunk/design/syn
Author: autrijus Date: Wed Apr 26 07:12:51 2006 New Revision: 8953 Modified: doc/trunk/design/syn/S03.pod Log: * S03: particle++ noted the omission of prefix unary = and -e -w -x etc from the operator table. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podWed Apr 26 07:12:51 2006 @@ -782,7 +782,7 @@ method postfix . .+ .? .* .() .[] .{} .«» .= autoincrement ++ -- exponentiation ** -symbolic unary ! + - ~ ? $ @ % & * ** +^ ~^ ?^ \ ^ +symbolic unary ! + - ~ ? $ @ % & * ** +^ ~^ ?^ \ ^ = -e -r -w -x etc. multiplicative * / % x xx +& +< +> ~& ~< ~> additive+ - ~ +| +^ ~| ~^ junctive and (all) &
[svn:perl6-synopsis] r8957 - doc/trunk/design/syn
Author: autrijus Date: Wed Apr 26 09:36:05 2006 New Revision: 8957 Modified: doc/trunk/design/syn/S02.pod Log: * S02: Explicitly define how Ps/Pe and BidiMirroring characters match, and resolve the one-to-many open/closing mapping by preferring the lower codepoint. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podWed Apr 26 09:36:05 2006 @@ -51,9 +51,17 @@ For some syntactic purposes, Perl distinguishes bracketing characters from non-bracketing. Bracketing characters are defined as any Unicode characters with either bidirectional mirrorings or Ps/Pe properties. -(In practice, though, you're safest using matching characters with +However, bidirectional mirroring characters with no corresponding +closing characters does not qualify as opening brackets. + +In practice, though, you're safest using matching characters with Ps/Pe properties, though ASCII angle brackets are a notable exception, -since they're bidirectional but not in the Ps/Pe set.) +since they're bidirectional but not in the Ps/Pe set. + +The C has two closing alternatives, C and C; +Perl 6 only recognizes the one with lower code point number, C, +as the closing brace. This policy also applies to new one-to-many +mappings introduced in the future. =back
[svn:perl6-synopsis] r8958 - doc/trunk/design/syn
Author: autrijus Date: Wed Apr 26 09:45:43 2006 New Revision: 8958 Modified: doc/trunk/design/syn/S02.pod Log: * U+201A and U+201E also have to go. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podWed Apr 26 09:45:43 2006 @@ -51,18 +51,20 @@ For some syntactic purposes, Perl distinguishes bracketing characters from non-bracketing. Bracketing characters are defined as any Unicode characters with either bidirectional mirrorings or Ps/Pe properties. -However, bidirectional mirroring characters with no corresponding -closing characters does not qualify as opening brackets. -In practice, though, you're safest using matching characters with -Ps/Pe properties, though ASCII angle brackets are a notable exception, -since they're bidirectional but not in the Ps/Pe set. +Characters with no corresponding closing characters does not qualify +as opening brackets. This includes the second section of the BidiMirroring +data table, as well as C and C. The C has two closing alternatives, C and C; Perl 6 only recognizes the one with lower code point number, C, as the closing brace. This policy also applies to new one-to-many mappings introduced in the future. +In practice, though, you're safest using matching characters with +Ps/Pe properties, though ASCII angle brackets are a notable exception, +since they're bidirectional but not in the Ps/Pe set. + =back =head1 Molecules
[svn:perl6-synopsis] r8961 - doc/trunk/design/syn
Author: autrijus Date: Wed Apr 26 10:05:19 2006 New Revision: 8961 Modified: doc/trunk/design/syn/S02.pod Log: * Further note that Ps/Pe dominates BidiMirroring, so U+298D maps to U+298E, and U+298E itself does not open brackets. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podWed Apr 26 10:05:19 2006 @@ -52,19 +52,23 @@ from non-bracketing. Bracketing characters are defined as any Unicode characters with either bidirectional mirrorings or Ps/Pe properties. +In practice, though, you're safest using matching characters with +Ps/Pe properties, though ASCII angle brackets are a notable exception, +since they're bidirectional but not in the Ps/Pe set. + Characters with no corresponding closing characters does not qualify as opening brackets. This includes the second section of the 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, +not C, and C itself is not a valid bracket opener. + The C has two closing alternatives, C and C; Perl 6 only recognizes the one with lower code point number, C, as the closing brace. This policy also applies to new one-to-many mappings introduced in the future. -In practice, though, you're safest using matching characters with -Ps/Pe properties, though ASCII angle brackets are a notable exception, -since they're bidirectional but not in the Ps/Pe set. - =back =head1 Molecules
[svn:perl6-synopsis] r8962 - doc/trunk/design/syn
Author: autrijus Date: Wed Apr 26 10:07:38 2006 New Revision: 8962 Modified: doc/trunk/design/syn/S02.pod Log: * S02: bump version from the unicode change; also merge in azuroth++'s typo fix, as well as paragraph reflow. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podWed Apr 26 10:07:38 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 10 Aug 2004 - Last Modified: 25 Apr 2006 + Last Modified: 26 Apr 2006 Number: 2 - Version: 33 + Version: 34 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -1591,18 +1591,19 @@ the syntax to be inconsistent with that, it is an error of the inconsistent signature variety. -If the unrecogized subname is followed by C<< postcircumfix:<( )> >>, it is -compiled as a provisional function call of the parenthesized form. +If the unrecognized subroutine name is followed by C<< postcircumfix:<( )> >>, +it is compiled as a provisional function call of the parenthesized form. If it is not, it is compiled as a provisional function call of the list operator form, which may or may not have an argument list. When in doubt, the attempt is made to parse an argument list. As with any list operator, an immediate postfix operator means there are no arguments, whereas anything following whitespace will be interpreted -as an argument list if possible. It is illegal for a provisional -subroutine call to be followed by a colon postfix, since such a colon -is allowed only on an indirect object or a method call in dot form. -(It is also allowed on a label when a statement is expected.) -So for any undeclared identifier "C": +as an argument list if possible. + +It is illegal for a provisional subroutine call to be followed by a +colon postfix, since such a colon is allowed only on an indirect object, +or a method call in dot form. (It is also allowed on a label when a +statement is expected.) So for any undeclared identifier "C": foo.bar# foo().bar -- postfix prevents args foo .bar # foo($_.bar) -- no postfix starts with whitespace @@ -1636,12 +1637,13 @@ The indirect object colon only ever dominates a simple term, where "simple" includes classes and variables and parenthesized expressions, but explicitly not method calls, because the colon will bind to a -trailing method call in preference. An indirect object that parses -as more than one token must be placed in parentheses, followed by -the colon. In short, only an identifier followed by a simple term -followed by a postfix colon is C parsed as an indirect object, -but that form will C be parsed as an indirect object regardless -of whether the identifier is otherwise declared. +trailing method call in preference. An indirect object that parses as +more than one token must be placed in parentheses, followed by the colon. + +In short, only an identifier followed by a simple term followed by a +postfix colon is C parsed as an indirect object, but that form +will C be parsed as an indirect object regardless of whether +the identifier is otherwise declared. =item *
[svn:perl6-synopsis] r9004 - doc/trunk/design/syn
Author: autrijus Date: Sat Apr 29 08:27:29 2006 New Revision: 9004 Modified: doc/trunk/design/syn/S02.pod Log: * S02: Change the section headings "Atoms" and "Molecules" to the more descriptive "Lexical Conventions" and "Whitespace and Comments". Reported by: Wassercrats Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podSat Apr 29 08:27:29 2006 @@ -23,7 +23,7 @@ These updates are not marked--if a Synopsis disagrees with its Apocalypse, assume the Synopsis is correct.) -=head1 Atoms +=head1 Lexical Conventions =over 4 @@ -71,7 +71,7 @@ =back -=head1 Molecules +=head1 Whitespace and Comments =over 4
[svn:perl6-synopsis] r9029 - doc/trunk/design/syn
Author: autrijus Date: Sat Apr 29 23:39:39 2006 New Revision: 9029 Modified: doc/trunk/design/syn/S06.pod Log: * S06: aufrank++ pointed out the quicksort example was still using the (?$foo) form in Sigs instead of ($foo?). Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podSat Apr 29 23:39:39 2006 @@ -1098,7 +1098,7 @@ Instead of specifying an array parameter as an array: -sub quicksort (@data, ?$reverse, ?$inplace) { +sub quicksort (@data, $reverse?, $inplace?) { my $pivot := shift @data; ... } @@ -1107,7 +1107,7 @@ specifying the parameter as if it were an anonymous array of parameters: -sub quicksort ([$pivot, [EMAIL PROTECTED], ?$reverse, ?$inplace) { +sub quicksort ([$pivot, [EMAIL PROTECTED], $reverse?, $inplace?) { ... }
[svn:perl6-synopsis] r9050 - doc/trunk/design/syn
Author: autrijus Date: Mon May 1 01:31:24 2006 New Revision: 9050 Modified: doc/trunk/design/syn/S02.pod Log: * S02: even more long dot fixes. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podMon May 1 01:31:24 2006 @@ -939,8 +939,9 @@ is the variable name, including any sigil. The package object can be derived from a type name by use of the C<::> postfix operator: -MyType. .::. .{'$foo'} -MyType::<$foo> # same thing +MyType::<$foo> +MyType.::.{'$foo'} # same thing with dots +MyType\ .::\ .{'$foo'} # same thing with long dots (Directly subscripting the type with either square brackets or curlies is reserved for various generic type-theoretic operations. In most other @@ -1677,9 +1678,9 @@ pairs. To align values of option pairs, you may use the "long dot" postfix forms: -:longkey. .($value) -:shortkey. . -:fookey. .{ $^a <=> $^b } +:longkey\ .($value) +:shortkey\ . +:fookey\ .{ $^a <=> $^b } These will be interpreted as
[svn:perl6-synopsis] r9051 - doc/trunk/design/syn
Author: autrijus Date: Mon May 1 01:33:08 2006 New Revision: 9051 Modified: doc/trunk/design/syn/S04.pod Log: * S04: minor typo cleanup. * S04: Document a consequence caused by the statement-terminating end-of-line block rule: # Without the trailing comma, this becomes a code block my $hash = { 1 => { 2 => 3, 4 => 5 }, }; In other words, nested hash literals in other hash literals must _not_ be statement-ending. Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podMon May 1 01:33:08 2006 @@ -121,7 +121,7 @@ =head1 Statement-ending blocks A line ending with a closing brace "C<}>", followed by nothing but -whitespace or comments, will terminates statement if an end of statement +whitespace or comments, will terminate a statement if an end of statement can occur there. That is, these two statements are equivalent: my $x = sub { 3 } @@ -135,6 +135,13 @@ sub { 3 } # the statement won't terminate here ]; +However, a nested hash block must be disambiguated by a trailing comma: + +# Without the trailing comma, this becomes a code block +my $hash = { +1 => { 2 => 3, 4 => 5 }, +}; + Because subroutine declarations are expressions, not statements, this is now invalid:
[svn:perl6-synopsis] r9052 - doc/trunk/design/syn
Author: autrijus Date: Mon May 1 01:35:22 2006 New Revision: 9052 Modified: doc/trunk/design/syn/S12.pod Log: * S12: The example @array.=sort is better written as @array .= sort as it's not impossible for "=sort" to be a postfix operator on its own. Modified: doc/trunk/design/syn/S12.pod == --- doc/trunk/design/syn/S12.pod(original) +++ doc/trunk/design/syn/S12.podMon May 1 01:35:22 2006 @@ -503,7 +503,7 @@ You can call an in-place mutator method like this: -@array.=sort; +@array .= sort; If there is a C operator defined, that will be used. Otherwise one will be autogenerated from the ordinary C operator, on the
[svn:perl6-synopsis] r9069 - doc/trunk/design/syn
Author: autrijus Date: Mon May 1 08:43:47 2006 New Revision: 9069 Modified: doc/trunk/design/syn/S03.pod Log: * S03: Correct the perl5ish "map" example to have an extra comma. 17:44 < TimToady> audreyt: foo {...} 1,2,3 is wrong, needs a comma. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podMon May 1 08:43:47 2006 @@ -698,8 +698,8 @@ The new operators C<< ==> >> and C<< <== >> are akin to UNIX pipes, but work with functions that accept and return lists. For example, - @result = map { floor($^x / 2) } - grep { /^ \d+ $/ } + @result = map { floor($^x / 2) }, + grep { /^ \d+ $/ }, @data; Can also now be written:
[svn:perl6-synopsis] r9071 - doc/trunk/design/syn
Author: autrijus Date: Mon May 1 09:18:16 2006 New Revision: 9071 Modified: doc/trunk/design/syn/S06.pod Log: * S06: Add Whatever to the list of "Undefined types". Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podMon May 1 09:18:16 2006 @@ -1311,6 +1311,7 @@ functions. (See S02 for how failures are handled.) Undef Undefined (can serve as a prototype object of any class) +WhateverWildcard (like undef, but subject to do-what-I-mean via MMD) Failure Failure (throws an exception if not handled properly) =head2 Immutable types
[svn:perl6-synopsis] r9076 - doc/trunk/design/syn
Author: autrijus Date: Mon May 1 10:32:02 2006 New Revision: 9076 Modified: doc/trunk/design/syn/S03.pod Log: * S03.pod: Retire lvalue undef and replace it with lvalue Whatever: # Perl 5 (undef, undef, $x) = (1,2,3); # Perl 6 (*, *, $x) = (1,2,3); Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podMon May 1 10:32:02 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 8 Mar 2004 - Last Modified: 30 Apr 2006 + Last Modified: 2 May 2006 Number: 3 - Version: 25 + Version: 26 =head1 Changes to existing operators @@ -671,6 +671,8 @@ @slice = @x[*;0;*];# any Int @slice = %x{*;'foo'}; # any keys in domain of 1st dimension @array[*] # flattens, unlike @array[] +(*, *, $x) = (1, 2, 3);# skip first two elements + # (same as lvalue "undef" in Perl 5) C is an undefined prototype object derived from C. As a type it is abstract, and may not be instantiated as a defined object.
[svn:perl6-synopsis] r9099 - doc/trunk/design/syn
Author: autrijus Date: Tue May 2 05:49:59 2006 New Revision: 9099 Modified: doc/trunk/design/syn/S03.pod Log: * S03: Minor typographical correction, changing the "===>" operator-lookalike to a more conventional comment. Reported by lichtkind++ Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podTue May 2 05:49:59 2006 @@ -376,9 +376,9 @@ defines both the C<[foo]> reduce operator and the C infix operator. Where appropriate, use of the infix form may be optimized like this: -$a foo $b ===>[foo] $a, $b -$a foo $b foo $c===>[foo] $a, $b, $c -... ... +# Original # Optimized +$a foo $b # [foo] $a, $b +$a foo $b foo $c# [foo] $a, $b, $c If the reduction operator is defined separately from the infix operator, it must associate the same way as the operator used:
[svn:perl6-synopsis] r9103 - doc/trunk/design/syn
Author: autrijus Date: Tue May 2 10:46:43 2006 New Revision: 9103 Modified: doc/trunk/design/syn/S02.pod Log: * S02: Clarify that subscripts evaluates under list context at RHS, but scalar context at LHS. Also adds some example code to illustrate various interactions. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podTue May 2 10:46:43 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 10 Aug 2004 - Last Modified: 1 May 2006 + Last Modified: 2 May 2006 Number: 2 - Version: 36 + Version: 37 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -589,10 +589,21 @@ =item * The context in which a subscript is evaluated is no longer controlled -by the sigil either. Subscripts are always evaluated in list context -on the assumption that slicing behavior is desired. If you need to -force inner context to scalar, we now have convenient single-character -context specifiers such as + for numbers and ~ for strings. +by the sigil either. Subscripts are always evaluated in scalar context +when used as a lvalue, and list context when used as a rvalue. + +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() =item *
[svn:perl6-synopsis] r9176 - doc/trunk/design/syn
Author: autrijus Date: Thu May 11 02:52:17 2006 New Revision: 9176 Modified: doc/trunk/design/syn/S06.pod Log: * S06: "but true" is now spelled as "but True" Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podThu May 11 02:52:17 2006 @@ -1575,7 +1575,7 @@ sub system { ... return $error but false if $error; -return 0 but true; +return 0 but True; } Properties are predeclared as roles and implemented as mixins--see S12.
[svn:perl6-synopsis] r9222 - doc/trunk/design/syn
Author: autrijus Date: Fri May 12 18:49:49 2006 New Revision: 9222 Modified: doc/trunk/design/syn/S06.pod Log: * S06: Only bare keys with valid identifier names are recognized as named arguments: doit when => 'now';# always a named arg doit 'when' => 'now'; # always a positonal arg doit 123 => 'now';# always a positonal arg doit :123;# always a positonal arg * S06: Named interpolation is now always via %() in the [,] zone: $pair = :when; doit $pair,1,2,3; # always a positional arg doit [,] %$pair,1,2,3; # always a named arg doit [,] %(get_pair()),1,2,3; # always a named arg doit [,] %('when' => 'now'),1,2,3; # always a named arg Modified: doc/trunk/design/syn/S06.pod == --- doc/trunk/design/syn/S06.pod(original) +++ doc/trunk/design/syn/S06.podFri May 12 18:49:49 2006 @@ -362,14 +362,21 @@ doit (when => 'now'),1,2,3;# always a positional arg doit 'when' => 'now',1,2,3;# always a positional arg +Only bare keys with valid identifier names are recognized as named arguments: + +doit when => 'now';# always a named arg +doit 'when' => 'now'; # always a positonal arg +doit 123 => 'now';# always a positonal arg +doit :123;# always a positonal arg + Going the other way, pairs intended as named arguments that don't look like pairs must be introduced with the C<[,]> reduction operator: $pair = :when; doit $pair,1,2,3; # always a positional arg -doit [,] $pair,1,2,3; # always a named arg -doit [,]('when' => 'now'),1,2,3;# always a named arg -doit [,] get_pair(),1,2,3; # always a named arg +doit [,] %$pair,1,2,3; # always a named arg +doit [,] %(get_pair()),1,2,3; # always a named arg +doit [,] %('when' => 'now'),1,2,3; # always a named arg Note that, to apply C<[,]> to a single arg you may need to use parentheses. In general it doesn't matter.
Re: ICU and Parrot
On Fri, May 31, 2002 at 06:18:55AM +0900, Dan Kogai wrote: > As a matter of fact GB18030 is ALREADY supported via Encode::HanExtra by > Autrijus Tang. The only reason GB18030 was not included in Encode main > is sheer size of the map. Yes, partly because it was not implemented algorithmically. :) I was browsing http://www-124.ibm.com/cvs/icu/charset/data/ucm/ and toying with uconv, and wondered: 1) Does Encode have (or intend to have) them all covered? 2) If not, would a Encode::ICU be wise? 3) A number of encodings are in HanExtra but not their ucm repository, namedly big5plus, big5ext and cccii. Is is wise to feed back to them under the name of e.g. perl-big5plus.ucm? Thanks, /Autrijus/ msg18951/pgp0.pgp Description: PGP signature
Re: ICU and Parrot
On Sat, Jun 01, 2002 at 02:20:15AM +0900, Dan Kogai wrote: > >2) If not, would a Encode::ICU be wise? > I'm not so sure. But if I were the one to implement Encode::ICU, it > will not be just a compiled collection of UCM files but a wrapper to all > library functions that ICU has to offer. I, for one, am too lazy for > that. That would be Text::Uconv's job, wouldn't it? Then Encode::ICU could just interface to that module instead. > >3) A number of encodings are in HanExtra but not their ucm repository, > > namedly big5plus, big5ext and cccii. Is is wise to feed back to them > > under the name of e.g. perl-big5plus.ucm? > You should in time and I should, too, because I have expanded UCM a > little so that you can define combined characters commonly seen in > Mac*. But I don't see any reason to be in hurry for the time being. Understood. In a related note: http://www.li18nux.org/docs/html/CodesetAliasTable-V10.html has spurred quite a bit discussion in Taiwan because of the mandated standardization of Big5 => TCA-BIG5, and Big5-HKSCS => HKSCS-BIG5 (i.e. the standard body first.) But it struck me as making lots of sense, if in a rather rigid way. Should Encode.pm probably add them to the Alias table, in the name of 'practical'? In particular, supporting CP-xxx (=> CPxxx) and ISO-646-US (=> US-ASCII) should be rather beneficial. /Autrijus/ msg18955/pgp0.pgp Description: PGP signature
split /(..)*/, 1234567890
In Pugs, the current logic for array submatches in split() is to stringify each element, and return them separately in the resulting list. To wit: pugs> split /(..)*/, 1234567890 ('', '12', '34', '56', '78', '90') Is this sane? Thanks, /Autrijus/ pgpUZCdoDMPb0.pgp Description: PGP signature
Re: Question about Parrot and Omniscient Debugging
On Tue, May 10, 2005 at 11:11:12AM -0500, [EMAIL PROTECTED] wrote: > Please excuse the possible 'out of left field' (as we say) aspect of this > question but I recently heard about Omniscient Debugging (ODB): > http://www.lambdacs.com/debugger/debugger.html This seems to require almost the same journaling capacity for STM (software transactional memory), although in STM's case we only mark updates for "shared" variables, whilst in ODB a journal is kept for all updates. It is conceivable to build this facility into the PMCs, much like how tied objects work, but my knowledge of parrot internals is insufficient to answer whether it will be difficult or not. Adding this sort of instrumentation is, however, much easier from a compiler's point of view; all you need to do is to generate extra instructions that records the timestamp, the variable being updated, and its original value. It will require a recompilation, and the result is difficult to share across different Parrot-targetting languages, so it's the less optimal choice. If you'd like to experiment with adding such instrumentation to Perl 6 (and history navigator, etc), I can give you a committer bit in Pugs -- you can do logged PMCs in the form of IVars, or by generating more instructions in the AST evaluation layer. The latter approach can be reused in the Parrot code generator, too. Thanks, /Autrijus/ pgpGkdEQtC5qX.pgp Description: PGP signature
Named rules and basic OO support landed.
This works: rule name { Larry | Matz | Guido } rule project { Perl | Ruby | Python } rule description { \s does \s } 'Larry does Perl' ~~ //; # true 'Larry does Java' ~~ //; # false This too: class Point { has $.x; has $.y; method show () { say "Coordinate: ($.x, $.y)" } method set ($x, $y) { $.x = $x; $.y = $y } } my $pt = Point.new(:x(10), :y(20)); $pt.show; # Coordinate: (10, 20) my $pt2 = $pt.clone; $pt.set(30, 40); $pt.show; # Coordinate: (30, 40) $pt2.show; # Coordinate: (10, 20) say(($pt ~~ Point).perl); # bool:true say(($pt ~~ Hash).perl);# bool::false Pugs's Parrot codegen backend needs to be updated to reflect both of them, but the basics are there. May the hackings commence. :) Thanks, /Autrijus/ pgpucZpT7ponX.pgp Description: PGP signature
Re: Named rules and basic OO support landed.
On Wed, May 11, 2005 at 09:19:50AM +0200, Leopold Toetsch wrote: > 2) named access > > x = getattribute o, "Point\0x" > > This needs a full qualified attribute name "Class" ~ NUL ~ "Attribute". > That's unusable for at least Python and probably more HLLs as the > compiler has to know in which class the attribute was defined. Yes. I've encountered this during my PGE::Hs hacking: .const string PGE_SUB_POS = "PGE::Match\x0@:capt" .const string PGE_SUB_NAMED = "PGE::Match\x0%:capt" I had no idea why the class name has to be fully qualified for attributes, whilst methods can be simply invoked. Pugs would have no easy way to figure out, at runtime, which attribute to dispatch to, as Perl 6 allows adding new attribute slots by eval'ing "class Foo { has $.x }" blocks, so attributes previously resolved as belong to a superclass may need to be redispatched. > We should just have: > x = getattribute o, "x" > and the set equivalent: > setattribute o, "x", x It'd definitely be better if the VM can keep track of this; otherwise I'd need to marshall the whole attribute table and do a lookup each time by hand, which would be slow (and non-interoperable) indeed. Thanks, /Autrijus/ pgpRQt7SPjRF1.pgp Description: PGP signature
Re: Nested captures
On Wed, May 11, 2005 at 08:30:42AM -0700, Larry Wall wrote: > On Wed, May 11, 2005 at 05:48:59PM +1000, Damian Conway wrote: > : But that's only the opinion of one(@Larry), not of $Larry. > > Let's go 0-based and make $0 =:= $/[0] so that $/[] is all the parens. > Our old $0 (P5's $&) could be $<> instead, short for $ or some > such. Both 0-based $0 etc and $<> are now implemented in Pugs. > It's already the case that p5-to-p6 is going to have a *wonderful* > time translating $7 to $1[2][0]... > > I wonder how much call there will be for a rule option that uses P6 > syntax but P5 paren binding with "push" semantics. Should it be an rule option, or simply an alternate way to address the content in $/? Something like $/.flattened_matches[10], perhaps? Thanks, /Autrijus/ pgpoESxp72tIn.pgp Description: PGP signature
Re: Nested captures
On Wed, May 11, 2005 at 12:01:35PM -0500, Patrick R. Michaud wrote: > Of course, this now begs the question -- where are things stored > after doing ... ? > > rx :perl5 / (don't) (ray) (me) (for solar) / > > My guess is that within the rule they're $1, $2, $3, etc. as before, Within the rule, $1 and $2 should still refer to the previous match, as in P5 rules they are spelled as \1 and \2. Of course, with P5 rules, they would not be written as \0 and \1 simply because they are running in Perl 6. However, the subst part of s/// may look weird: pugs> $_ = "foo foo"; s:P5/(\w+) \1/--$0--/; $_ '--foo--' But it's probably unavoidable. Thanks, /Autrijus/ pgp7CKwIDXwVM.pgp Description: PGP signature
Re: single element lists
On Wed, May 11, 2005 at 01:11:45PM -0700, Larry Wall wrote: > On Wed, May 11, 2005 at 11:45:12AM -0500, Jonathan Scott Duff wrote: > : > : We're discussing the proper semantics of (1)[0] on #perl6. Here's > : where we're at so far: > : > : 1. specialise ()[] to parse as (,)[] > : 2. scalars are singleton lists, so ()[] naturally > : 3. make (1)[0] die horribly. > : > I think it has to be #1. We can't have (@foo)[0] working at two different > indirection levels depending on whether @foo == 1. Hm? Under #2, no matter whether @foo is (1) or (1,2), the construct (@foo)[0] would always means @foo.[0]. Not sure how the length of @foo matters here. Thanks, /Autrijus/ pgpiDLzKqsG2b.pgp Description: PGP signature
(1,(2,3),4)[2]
In a somewhat related topic: pugs> (1,(2,3),4)[2] 4 Because the invocant to .[] assumes a Singular context. I'm not sure how any invocant can assume a Plural context anyway, so this behaviour seems correct. Is it, though? :) Thanks, /Autrijus/ pgpQf1TyWmCFa.pgp Description: PGP signature
Re: (1,(2,3),4)[2]
On Wed, May 11, 2005 at 03:00:15PM -0600, Luke Palmer wrote: > On 5/11/05, Autrijus Tang <[EMAIL PROTECTED]> wrote: > > In a somewhat related topic: > > > > pugs> (1,(2,3),4)[2] > > 4 > > > > Because the invocant to .[] assumes a Singular context. > > Right, but the *inside* of the invocant is still a list, so it's in > list context. I think that line should return 3. You're totally right, and I was clearly wahnsinnig. It now returns 3. Thanks, /Autrijus/ pgpLFhPsoPG5N.pgp Description: PGP signature
Re: single element lists
On Wed, May 11, 2005 at 02:12:41PM -0700, Larry Wall wrote: > On Thu, May 12, 2005 at 04:19:02AM +0800, Autrijus Tang wrote: > : Hm? Under #2, no matter whether @foo is (1) or (1,2), the construct > : (@foo)[0] would always means @foo.[0]. Not sure how the length of @foo > : matters here. > > Tell you what, let's require P5's (...)[] to be translated to [...][], > so (...)[] should assume scalar context that will return some kind of > array reference. (What Luke said about (1,(2,3),4)[] still holds, though. > Commas create lists, and lists by default impose list context, and > parens are only for grouping in lists, not scalarifiying.) Sure (and done). Now that #1 is eliminated, the question is now whether a simple scalar can be treated as a small (one-element) array reference, much like a simple pair can be treated as a small (one-element) hash reference. 1.[0]; # evaluates to 1? If yes, then (1)[0] means the same as 1.[0] and 1.[0][0][0]. If no, (1)[0] is a runtime error just like 1.[0] -- i.e. unable to find the matching .[] multisub under Int or its superclasses. Thanks, /Autrijus/ pgpeoBPwdpegh.pgp Description: PGP signature
Re: t/oo/class/basic.t path for class Foo::Bar {} failure
Thanks, both yours and Shillo's tests are applied (and implemented). /Autrijus/ pgpi79NWrtGna.pgp Description: PGP signature
Re: Nested captures
On Thu, May 12, 2005 at 12:37:06AM +0200, Fagyal Csongor wrote: > Damian Conway wrote: > > >print @array[1st..($n)th]; > > Sounds cool, but what about $n = 0; ? Then it would be 0..-1, an empty range. /Autrijus/ pgpRRkOMafCIK.pgp Description: PGP signature
Re: (1,(2,3),4)[2]
On Wed, May 11, 2005 at 03:00:15PM -0600, Luke Palmer wrote: > On 5/11/05, Autrijus Tang <[EMAIL PROTECTED]> wrote: > > In a somewhat related topic: > > > > pugs> (1,(2,3),4)[2] > > 4 > > > > Because the invocant to .[] assumes a Singular context. > > Right, but the *inside* of the invocant is still a list, so it's in > list context. I think that line should return 3. Okay. Here is the current (all-passing) t/data_types/nested_arrays.t: { my @a = (1,2,[3,4]); my $a = (1,2,[3,4]); my @b = [1,2,[3,4]]; my $b = [1,2,[3,4]]; my @c = (1,2,(3,4)); my $c = (1,2,(3,4)); my @d = [1,2,(3,4)]; my $d = [1,2,(3,4)]; is([EMAIL PROTECTED], 3, 'Array length, nested []'); is(+$a, 3, 'Array ref length, nested []'); is([EMAIL PROTECTED], 1, 'Array length, nested [], outer []s'); is(+$b, 3, 'Array ref length, nested [], outer []s'); is(+$c, 4, 'Array ref length, nested ()'); is([EMAIL PROTECTED], 4, 'Array length, nested ()'); is([EMAIL PROTECTED], 1, 'Array length, nested (), outer []s'); is(+$d, 4, 'Array ref length, nested (), outer []s'); } Please sanity-check. :-) Thanks, /Autrijus/ pgpSkGBNuwZIH.pgp Description: PGP signature
Re: small typo in PBC_COMPAT
On Wed, May 11, 2005 at 06:09:00PM -0400, Dino Morelli wrote: > >Feel free to correct 'no_plan'. I'll happily apply any and all > >patches to the tests, and those with commit privs are welcome > >to directly modify the t/p6rules/*.t files at any time. > > > > Speak of the devil -- I started working on more unit tests for > p6rules today, starting with the things Patrick listed the other day in > his PGE features update: This may be helpful, too: http://svn.openfoundry.org/pugs/t/rules/Disabled/rules.t If you'd like to converted it back to t/p6rules/*.t and included in Parrot itself, I'd be grateful. :) Thanks, /Autrijus/ pgpLdNeWcYLzt.pgp Description: PGP signature
Re: split /(..)*/, 1234567890
On Thu, May 12, 2005 at 04:53:06PM +0200, "TSa (Thomas Sandlaï)" wrote: > Autrijus Tang wrote: > >pugs> split /(..)*/, 1234567890 > >('', '12', '34', '56', '78', '90') > > > >Is this sane? > > Why the empty string match at the start? I don't know, I didn't invent that! :-) $ perl -le 'print join ",", split /(..)/, 123' ,12,3 Thanks, /Autrijus/ pgpMbWBoMX6xB.pgp Description: PGP signature
[RELEASE] Pugs 6.2.3 released!
On behalf of the Pugs team, I am delighted to announce the release of Pugs 6.2.3, with Parrot embedding, Perl 6 Rules support (via PGE), an initial sketch of OO system. Multi-thread programming with async/kill/join/detach is now supported as well. Also of note are many new, working modules under ext/, some using the newly supported OO system, some using an inside-out OO system based on closures. Pugs is available from a nearby CPAN mirror, or from pugscode.org: http://pugscode.org/dist/Perl6-Pugs-6.2.3.tar.gz SIZE = 894640 SHA1 = 16599281a8a103d13e4f0041ccba06bddff28f83 As Pugs now requires Parrot 0.2.0 or later for Rules support, you may wish to install Parrot first: http://www.cpan.org/modules/by-authors/id/L/LT/LTOETSCH/parrot-0.2.0.tar.gz SIZE = 2696634 SHA1 = da4231fda3b7fcb842a886bef3d86d477ecc34e6 Thank to all the lambdacamels for flying with Pugs! :-) Enjoy, /Autrijus/ == Changes for 6.2.3 - May 12, 2005 === Pugs Internals * Pugs can now embed Parrot or use an external `parrot` executable ** Under embedded mode, Pugs is a registered Parrot compiler ** `eval_parrot` and `require_parrot` builtins for running PIR code ** `pugs -BParrot` can compile Perl 6 program to PIR and run it in-memory * Perl 6 Rules support via Parrot/PGE: ** Named rules and subrule support ** The former `$0` (entire match) is now `$<>` ** `$0` is now the same as `~$/[0]`, i.e. the same as Perl 5's `$1` ** `.from`, `.to`, `.matches` ** `//`, `rx//`, `m//`, `rule{}` ** `s///` and `//` in statement level operates on `$_` * Basic Object support: ** Accessors generated for public attributes ** Identity operator: `=:=` ** Method chaining: `$foo.bar().baz()` ** Method invocants `foo ($self: $x)` and topicalized invocants in `$_` ** Public and private attributes, as well as `has $.attr is rw` ** `$obj ~~ Class` support ** `$obj.clone()` support ** `class Foo {}` works (no inheritance yet) * Experimental `eval_yaml()` support to parse YAML streams * Experimental support for prefix reduce metaoperator `[+]` * Hyper operators now works on arrays too * Improved `.perl()` format for array, hash and pair objects * Much faster random access to arrays; it's now O(1) instead of O(n) * Much improved MMD support * New `is lazy` trait for parameters * Refactoring of large Haskell modules to improve compilation speed * Support for building a profiled Pugs * Undef in grouped lhs: `my ($x, undef, $y) = 1..3;` is now legal * `$thread.kill`, `$thread.detach`, `$thread.join` * `%hash.pick`, [EMAIL PROTECTED] and `(list).pick` * `reduce` primitive * `state $var` implemented * `system(Str: List)` and `exec(Str: List)` on Unix platforms === Bundled Modules * All modules have their own `ChangeLog` now * `Algorithm::TokenBucket`, with closure objects * `Config::Tiny`, with closure objects * `Kwid::Event::Parser`, with procedures * `Net::IRC`, with closure objects * `Perl::MetaModel`, prototype of Perl 6 OO meta-model in Perl 6 * `Pod::Stream::Parser` renamed to `Pod::Event::Parser` and added more functionality * `Set`, with Perl 6 objects * `Test::Builder`, with Perl 6 objects (parses, but does not working yet) * `Tree::Simple`, with closure objects === Tests, Examples and Documentations * Many new test and several tests refactored, we now have 4921 tests * Documentation for `hangman.p6` added in `examples/games/hangman.pod` * New "Monads in Perl 6" example in `examples/functional/monads.p6` * Script to generate a Pugs Live CD in `util/livecd` * Several IRC bots added to `examples/network` including svnbot and logbot * TODO tests now use `:todo` for better reporting * The first Perl 6 poem in `examples/poetry/` === Bug Fixes * Logical short-circuiting operators no longer flattens references * Prohibit Array and Hash dereference on plain values * Slurpy context no longer flattens * Stringifying IO handles is no longer fatal * `$*PID` now works on Win32 * `%*ENV` now completely works on Win32 * `(a => 3+4)` is now parsed as `(a => (3+4))`, not `(a => 3)+4` * `any().pick` no longer dies * `my @x = [1]; @x[0][0] = 2` should now work * `next` in nested `for {}` blocks no longer escapes the outer loop * `to => 123` parses again; arrow pairs now always trumps unary functions * `{}` in P5 rules is no longer closure interpolation pgpcgs0Sfnn9X.pgp Description: PGP signature
Numification of captured match
Thit has led to surprising results in Pugs's Net::IRC: if 'localhost:80' ~~ /^(.+)\:(\d+)$/ { my $socket = connect($0, $1); } If $1 is a match object here, and connect() assumes Int on its second argument, then it will connect to port 1, as the match object numifies to 1 (indicating a successful match). I "fixed" this for 6.2.3 by flattening $0, $1, $2 into plain scalars (for nonquantified matches), and use $/[0] etc to store match objects, but I'm not sure this treatment is right. Is it really intended that we get into habit of writing this? if 'localhost:80' ~~ /^(.+)\:(\d+)$/ { my $socket = connect(~$0, +$1); } It looks... weird. :) Thanks, /Autrijus/ pgpn8chlVn4Ob.pgp Description: PGP signature