Author: larry Date: Thu Aug 2 16:19:18 2007 New Revision: 14431 Modified: doc/trunk/design/syn/S03.pod doc/trunk/design/syn/S11.pod doc/trunk/design/syn/S12.pod
Log: Clarification of autoincrement semantics requested by pmichaud++ self does not expand in list context typos Modified: doc/trunk/design/syn/S03.pod ============================================================================== --- doc/trunk/design/syn/S03.pod (original) +++ doc/trunk/design/syn/S03.pod Thu Aug 2 16:19:18 2007 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 8 Mar 2004 - Last Modified: 15 Jun 2007 + Last Modified: 2 Aug 2007 Number: 3 - Version: 117 + Version: 118 =head1 Overview @@ -28,11 +28,11 @@ Level Examples ===== ======== - Terms 42 3.14 "eek" qq["foo"] $x :!verbose + Terms 42 3.14 "eek" qq["foo"] $x :!verbose @$array Method postfix .meth .+ .? .* .() .[] .{} .<> .«» .:: .= .^ .: Autoincrement ++ -- Exponentiation ** - Symbolic unary ! + - ~ ? $ @ % & | +^ ~^ ?^ \ ^ = + Symbolic unary ! + - ~ ? | +^ ~^ ?^ \ ^ = Multiplicative * / % x xx +& +< +> ~& ~< ~> ?& div mod Additive + - ~ +| +^ ~| ~^ ?| ?^ Junctive and (all) & @@ -47,7 +47,7 @@ Loose unary true not Comma operator , List infix Z minmax X X~X X*X XeqvX - List prefix = : print push say die map substr ... [+] [*] any all + List prefix = : print push say die map substr ... [+] [*] any $ @ Loose and and Loose or or xor err Terminator ; <==, ==>, <<==, ==>>, {...}, modifiers, extra ), ], } @@ -355,10 +355,19 @@ say $x unless %seen{$x}++; Increment of a C<Str> (in a suitable container) works similarly to -Perl 5 except that the final alphanumeric sequence in the string is -incremented regardless of what comes before it. For its typical use -of incrementing a filename, you don't have to worry about the path name, but -you do still have to worry about the extension, so you probably want to say +Perl 5, but is generalized slightly. First, the string is examined +to see if it could be the string representation of a number in +any common representation, including floating point and radix +notation. (Surrounding whitespace is also allowed around such a +number.) If it appears to be a number, it is converted to a number +and incremented as a number. Otherwise, a scan is made for the +final alphanumeric sequence in the string. Unlike in Perl 5, this +alphanumeric sequence need not be anchored to the beginning of the +string, nor does it need to begin with an alphabetic character; the +final sequence in the string matching C<\w+> is incremented regardless +of what comes before it. For its typical use of incrementing a +filename, you don't have to worry about the path name, but you do +still have to worry about the extension, so you probably want to say my $fh = open $filename++ ~ '.jpg'; @@ -366,7 +375,7 @@ $filename ~~ s[ <( <<\w+>> )> \.\w+$] = $().succ; -Perl 6 also supports C<Str> decrement. +Perl 6 also supports C<Str> decrement with similar semantics. Increment and decrement are defined in terms of the C<.succ> and C<.pred> methods on the type of object in the C<Scalar> container. Modified: doc/trunk/design/syn/S11.pod ============================================================================== --- doc/trunk/design/syn/S11.pod (original) +++ doc/trunk/design/syn/S11.pod Thu Aug 2 16:19:18 2007 @@ -314,7 +314,7 @@ When specifying the version of your own module, C<1.2> is equivalent to C<1.2.0>, C<1.2.0.0>, and so on. However C<use> searches for modules matching a version prefix, so the subversions are wildcarded, -and in this context C<< :vers<1.2> >> really means C<< :vers<1.2.*> >>. +and in this context C<< :ver<1.2> >> really means C<< :ver<1.2.*> >>. If you say: use v6; @@ -376,7 +376,7 @@ from other languages. The C<from> adverb also parses any additional parts as short-form arguments. For instance: - use Whiteness:from<perl5>:name<Acme::Bleach>ver<1.12>:auth<cpan:DCONWAY>; + use Whiteness:from<perl5>:name<Acme::Bleach>:ver<1.12>:auth<cpan:DCONWAY>; use Whiteness:from<perl5 Acme::Bleach 1.12 cpan:DCONWAY>; # same thing The string form of a version recognizes the C<*> wildcard in place of any Modified: doc/trunk/design/syn/S12.pod ============================================================================== --- doc/trunk/design/syn/S12.pod (original) +++ doc/trunk/design/syn/S12.pod Thu Aug 2 16:19:18 2007 @@ -180,6 +180,22 @@ multi method doit ($x: $a; $b; $c) { ... } +If you declare an explicit invocant for an Array type using an array variable, +you may use that directly in list context to produce its elements + + method push3 (@x: $a, $b, $c) { ... any(@x) ... } + +Note that the C<self> function is not context sensitive and thus always +returns the current object as a single item even in list context. +Hence if your current object happens to be an array but you did not +declare it with an explicit array variable. you need to explicitly +access the elements of the array somehow: + + any(self) # WRONG + any(self[]) # okay + any(@(self)) # okay + any(@self) # WRONG unless you declared @self yourself + Private methods are declared using C<my>: my method think (Brain $self: $thought)