Front page | perl.perl6.language |
Postings from July 2006
[svn:perl6-synopsis] r10156 - doc/trunk/design/syn
From:
larry
Date:
July 12, 2006 18:05
Subject:
[svn:perl6-synopsis] r10156 - doc/trunk/design/syn
Message ID:
20060713010525.37223CBABC@x12.develooper.com
Author: larry
Date: Wed Jul 12 18:05:24 2006
New Revision: 10156
Modified:
doc/trunk/design/syn/S02.pod
doc/trunk/design/syn/S03.pod
Log:
Clarifications from Smylers++ and ajs++.
Modified: doc/trunk/design/syn/S02.pod
==============================================================================
--- doc/trunk/design/syn/S02.pod (original)
+++ doc/trunk/design/syn/S02.pod Wed Jul 12 18:05:24 2006
@@ -12,9 +12,9 @@
Maintainer: Larry Wall <larry@wall.org>
Date: 10 Aug 2004
- Last Modified: 10 July 2006
+ Last Modified: 12 July 2006
Number: 2
- Version: 49
+ Version: 50
This document summarizes Apocalypse 2, which covers small-scale
lexical items and typological issues. (These Synopses also contain
@@ -1215,7 +1215,7 @@
way, but with any radix it's not clear whether the exponentiator should
be 10 or the radix, and this makes it explicit:
- 0b1.1e10 illegal, could be read as any of:
+ 0b1.1e10 ILLEGAL, could be read as any of:
:2<1.1> * 2 ** 10 1536
:2<1.1> * 10 ** 10 15,000,000,000
@@ -1747,15 +1747,15 @@
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>":
- foo.bar # foo().bar -- illegal postfix, must use foo().bar
+ foo.bar # ILLEGAL -- postfix must use foo().bar
foo .bar # foo($_.bar) -- no postfix starts with whitespace
- foo\ .bar # foo().bar -- illegal long dot, use foo()\ .bar
- foo++ # foo()++ -- illegal postfix, must use foo()++
+ foo\ .bar # ILLEGAL -- long dot must use foo()\ .bar
+ foo++ # ILLEGAL -- postfix must use foo()++
foo 1,2,3 # foo(1,2,3) -- args always expected after listop
foo + 1 # foo(+1) -- term always expected after listop
foo; # foo(); -- no postfix, but no args either
foo: # label -- must be label at statement boundary.
- -- illegal otherwise
+ -- ILLEGAL otherwise
foo: bar: # two labels in a row, okay
.foo: # $_.foo: 1 -- must be "dot" method with : args
.foo(1) # $_.foo(1) -- must be "dot" method with () args
@@ -1768,13 +1768,13 @@
foo $bar: 1 # $bar.foo(1) -- indirect object even if declared sub
-- $bar considered one token
foo (bar()): # bar().foo(1) -- even if foo declared sub
- foo bar(): # illegal -- bar() is two tokens.
+ foo bar(): # ILLEGAL -- bar() is two tokens.
foo .bar: # foo(.bar:) -- colon chooses .bar to listopify
foo bar baz: 1 # foo(baz.bar(1)) -- colon controls "bar", not foo.
foo (bar baz): 1 # bar(baz()).foo(1) -- colon controls "foo"
- $foo $bar # illegal -- two terms in a row
- $foo $bar: # illegal -- use $bar.$foo for indirection
- (foo bar) baz: 1 # illegal -- use $baz.$(foo bar) for indirection
+ $foo $bar # ILLEGAL -- two terms in a row
+ $foo $bar: # ILLEGAL -- use $bar.$foo for indirection
+ (foo bar) baz: 1 # ILLEGAL -- use $baz.$(foo bar) for indirection
The indirect object colon only ever dominates a simple term, where
"simple" includes classes and variables and parenthesized expressions,
Modified: doc/trunk/design/syn/S03.pod
==============================================================================
--- doc/trunk/design/syn/S03.pod (original)
+++ doc/trunk/design/syn/S03.pod Wed Jul 12 18:05:24 2006
@@ -12,9 +12,9 @@
Maintainer: Larry Wall <larry@wall.org>
Date: 8 Mar 2004
- Last Modified: 10 Jul 2006
+ Last Modified: 12 Jul 2006
Number: 3
- Version: 45
+ Version: 46
=head1 Changes to existing operators
@@ -249,18 +249,18 @@
say foo ($bar+1),$baz say(foo($bar+1, $baz));
say foo .($bar+1),$baz say(foo($_.($bar+1), $baz));
- say foo[$bar+1],$baz illegal, need foo()[]
- say foo.[$bar+1],$baz illegal, need foo().[]
+ say foo[$bar+1],$baz ILLEGAL, need foo()[]
+ say foo.[$bar+1],$baz ILLEGAL, need foo().[]
say foo [$bar+1],$baz say(foo([$bar+1], $baz));
say foo .[$bar+1],$baz say(foo($_.[$bar+1], $baz));
- say foo{$bar+1},$baz illegal, need foo(){}
- say foo.{$bar+1},$baz illegal, need foo().{}
+ say foo{$bar+1},$baz ILLEGAL, need foo(){}
+ say foo.{$bar+1},$baz ILLEGAL, need foo().{}
say foo {$bar+1},$baz say(foo({$bar+1}, $baz));
say foo .{$bar+1},$baz say(foo($_.{$bar+1}, $baz));
- say foo<$bar+1>,$baz illegal, need foo()<>
- say foo.<$bar+1>,$baz illegal, need foo().<>
+ say foo<$bar+1>,$baz ILLEGAL, need foo()<>
+ say foo.<$bar+1>,$baz ILLEGAL, need foo().<>
say foo <$bar+1>,$baz say(foo(<$bar+1>, $baz));
say foo .<$bar+1>,$baz say(foo($_.<$bar+1>, $baz));
@@ -271,7 +271,7 @@
any <a b c> any('a','b','c') # term
any()<a b c> (any).{'a','b','c'} # postfix
any() < $x (any) < $x # infix
- any<a b c> [syntax error] # illegal postfix
+ any<a b c> ILLEGAL # stealth postfix
This will seem unfamiliar and "undwimmy" to Perl 5 programmers, who
are used to a grammar that sloppily hardwires a few postfix operators
@@ -279,6 +279,18 @@
whitespace dependency in order to gain a completely extensible class
of postfix operators.
+Also note that the postfix restriction applies only to list operators;
+it doesn't apply to methods. It is legal to say
+
+ $foo.bar<a b c>
+
+to mean
+
+ $foo.bar().{'a','b','c'}
+
+because methods never assume there are arguments unless followed by
+parentheses or a colon.
+
=item * A list operator's arguments are also terminated by a closure
that is not followed by a comma or colon. (And a semicolon is implied if
the closure is the final thing on a line.)
-
[svn:perl6-synopsis] r10156 - doc/trunk/design/syn
by larry