Author: larry Date: Fri Jun 15 12:10:26 2007 New Revision: 14422 Modified: doc/trunk/design/syn/S03.pod doc/trunk/design/syn/S12.pod
Log: some cleanup suggestions by dduncan++ spec out several migration error catching policies, like infix:<?> pseudo-op Modified: doc/trunk/design/syn/S03.pod ============================================================================== --- doc/trunk/design/syn/S03.pod (original) +++ doc/trunk/design/syn/S03.pod Fri Jun 15 12:10:26 2007 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 8 Mar 2004 - Last Modified: 2 Jun 2007 + Last Modified: 15 Jun 2007 Number: 3 - Version: 116 + Version: 117 =head1 Overview @@ -220,6 +220,10 @@ .meth # call on $_ .=meth # modify $_ +Note that this may occur only where a term is expected. Where a +postfix is expected, it is a postfix. If only an infix is expected +(that is, after a term with intervening whitespace), it is a syntax error. + =item * Listop (leftward) @@ -312,6 +316,16 @@ $x.:<++> # prefix:<++>($x) +=item * + +There is specifically no C<< infix:<.> >> operator, so + + $foo . $bar + +will always result in a compile-time error indicating the user should +use C<< infix:<~> >> instead. This is to catch an error likely to +be made by Perl 5 programmers learning Perl 6. + =back =head2 Autoincrement precedence @@ -377,14 +391,14 @@ =item * -Autoincrement prefix:<++> or postfix:<++> operator +Autoincrement C<< prefix:<++> >> or C<< postfix:<++> >> operator $x++ ++$x; =item * -Autodecrement prefix:<--> or postfix:<--> operator +Autodecrement C<< prefix:<--> >> or C<< postfix:<--> >> operator $x-- --$x @@ -397,7 +411,7 @@ =item * -infix:<**> exponentiation operator +C<< infix:<**> >> exponentiation operator $x ** 2 @@ -418,7 +432,7 @@ =item * -prefix:<?>, boolean context +C<< prefix:<?> >>, boolean context ?$x @@ -428,7 +442,7 @@ =item * -prefix:<!>, boolean negation +C<< prefix:<!> >>, boolean negation !$x @@ -437,7 +451,7 @@ =item * -prefix:<+>, numeric context +C<< prefix:<+> >>, numeric context +$x @@ -450,7 +464,7 @@ =item * -prefix:<->, numeric negation +C<< prefix:<-> >>, numeric negation -$x @@ -458,7 +472,7 @@ =item * -prefix:<~>, string context +C<< prefix:<~> >>, string context ~$x @@ -467,7 +481,7 @@ =item * -prefix:<|>, flatten object into arglist +C<< prefix:<|> >>, flatten object into arglist | $capture @@ -476,7 +490,7 @@ =item * -prefix:<+^>, numeric bitwise negation +C<< prefix:<+^> >>, numeric bitwise negation +^$x @@ -484,14 +498,14 @@ =item * -prefix:<~^>, string bitwise negation +C<< prefix:<~^> >>, string bitwise negation ~^$x Coerces to string buffer and then does bitwise negation on each element. =item * -prefix:<?^>, boolean bitwise negation +C<< prefix:<?^> >>, boolean bitwise negation ?^$x @@ -499,7 +513,7 @@ =item * -prefix:<\>, Capture constructor +C<< prefix:<\> >>, Capture constructor \$x [EMAIL PROTECTED] @@ -511,7 +525,7 @@ =item * -prefix:<^>, upto operator +C<< prefix:<^> >>, upto operator ^$limit @@ -520,7 +534,7 @@ =item * -prefix:<=>, iterate iterator +C<< prefix:<=> >>, iterate iterator =$iterator @@ -543,7 +557,7 @@ =item * -infix:<*> +C<< infix:<*> >> $x*$y @@ -551,7 +565,7 @@ =item * -infix:</> +C<< infix:</> >> $numerator / $denominator @@ -571,7 +585,7 @@ =item * -infix:<div>, generic division +C<< infix:<div> >>, generic division $numerator div $denominator @@ -589,7 +603,7 @@ =item * -infix:<%>, modulus +C<< infix:<%> >>, modulus $x % $mod @@ -597,15 +611,15 @@ =item * -infix:<mod>, generic modulus +C<< infix:<mod> >>, generic modulus $x mod $mod -Dispatches to the infix:<mod> multi most appropriate to the operand types. +Dispatches to the C<< infix:<mod> >> multi most appropriate to the operand types. =item * -infix:<x>, string/buffer replication +C<< infix:<x> >>, string/buffer replication $string x $count @@ -620,7 +634,7 @@ =item * -infix:<xx>, list replication +C<< infix:<xx> >>, list replication @list xx $count @@ -637,7 +651,7 @@ =item * -infix:{'+&'}, numeric bitwise and +C<< infix:{'+&'} >>, numeric bitwise and $x +& $y @@ -645,13 +659,13 @@ =item * -infix:{'+<'}, numeric shift left +C<< infix:{'+<'} >>, numeric shift left $integer +< $bits =item * -infix:{'+>'}, numeric shift right +C<< infix:{'+>'} >>, numeric shift right $integer +> $bits @@ -660,19 +674,19 @@ =item * -infix:<~&>, buffer bitwise and +C<< infix:<~&> >>, buffer bitwise and $x ~& $y =item * -infix:{'~<'}, buffer bitwise shift left +C<< infix:{'~<'} >>, buffer bitwise shift left $buf ~< $bits =item * -infix:{'~>'}, buffer bitwise shift right +C<< infix:{'~>'} >>, buffer bitwise shift right $buf ~> $bits @@ -681,7 +695,7 @@ =item * -infix:<?&>, boolean bitwise and +C<< infix:<?&> >>, boolean bitwise and $x ?& $y @@ -697,55 +711,55 @@ =item * -infix:<+>, numeric addition +C<< infix:<+> >>, numeric addition $x + $y =item * -infix:<->, numeric subtraction +C<< infix:<-> >>, numeric subtraction $x - $y =item * -infix:<~>, string/buffer concatenation +C<< infix:<~> >>, string/buffer concatenation $x ~ $y =item * -infix:<+|>, numeric bitwise inclusive or +C<< infix:<+|> >>, numeric bitwise inclusive or $x +| $y =item * -infix:<+^> numeric bitwise exclusive or +C<< infix:<+^> >> numeric bitwise exclusive or $x +^ $y =item * -infix:<~|>, buffer bitwise inclusive or +C<< infix:<~|> >>, buffer bitwise inclusive or $x ~| $y =item * -infix:<~^> buffer bitwise exclusive or +C<< infix:<~^> >> buffer bitwise exclusive or $x ~^ $y =item * -infix:<?|>, boolean bitwise inclusive or +C<< infix:<?|> >>, boolean bitwise inclusive or $x ?| $y =item * -infix:<?^> boolean bitwise exclusive or +C<< infix:<?^> >> boolean bitwise exclusive or $x ?^ $y @@ -757,7 +771,7 @@ =item * -infix:<&>, all() operator +C<< infix:<&> >>, all() operator $x & $y @@ -769,13 +783,13 @@ =item * -infix:<|>, any() operator +C<< infix:<|> >>, any() operator $x | $y =item * -infix:<^>, one() operator +C<< infix:<^> >>, one() operator $x ^ $y @@ -802,13 +816,13 @@ =item * -infix:<but> +C<< infix:<but> >> $value but Mixin =item * -infix:<does> +C<< infix:<does> >> $object does Mixin @@ -866,7 +880,7 @@ =item * -infix:<==> etc. +C<< infix:<==> >> etc. == != < <= > >= @@ -874,7 +888,7 @@ =item * -infix:<eq> etc. +C<< infix:<eq> >> etc. eq ne lt le gt ge @@ -956,7 +970,7 @@ =item * -infix:<&&>, short-circuit and +C<< infix:<&&> >>, short-circuit and $condition && $whentrue @@ -973,7 +987,7 @@ =item * -infix:<||>, short-circuiting inclusive-or +C<< infix:<||> >>, short-circuiting inclusive-or $condition || $whenfalse @@ -988,7 +1002,7 @@ =item * -infix:<^^>, exclusive-or +C<< infix:<^^> >>, exclusive-or $x ^^ $y @@ -999,7 +1013,7 @@ =item * -infix:<//>, defined-or +C<< infix:<//> >>, defined-or $value // $default @@ -1073,6 +1087,14 @@ my $x = hmm() ?? 1 !! 2; # much better +=item * + +C<< infix:<?> >> + +To catch likely errors by people familiar with C-derived languages +(including Perl 5), a bare question mark in infix position will +produce an error suggesting that the user use C<?? !!> instead. + =back =head2 Item assignment precedence @@ -1081,7 +1103,7 @@ =item * -infix:<=> +C<< infix:<=> >> $x = 1, $y = 2; @@ -1090,7 +1112,7 @@ =item * -infix:<:=>, run-time binding +C<< infix:<:=> >>, run-time binding $signature := $capture @@ -1125,7 +1147,7 @@ =item * -infix:<::=>, compile-time binding +C<< infix:<::=> >>, compile-time binding $signature ::= $capture @@ -1135,7 +1157,7 @@ =item * -infix:{'=>'}, Pair constructor +C<< infix:{'=>'} >>, Pair constructor foo => 1, bar => "baz" @@ -1163,13 +1185,13 @@ =item * -prefix:<true> +C<< prefix:<true> >> true any(@args) eq '-v' | '-V' =item * -prefix:<not> +C<< prefix:<not> >> not any(@args) eq '-v' | '-V' @@ -1181,7 +1203,7 @@ =item * -infix:<,>, the argument separator +C<< infix:<,> >>, the argument separator 1, 2, 3, @many @@ -1201,13 +1223,13 @@ =item * -infix:<Z>, the zip operator +C<< infix:<Z> >>, the zip operator 1,2 Z 3,4 # (1,3),(2,4) =item * -infix:<minmax>, the minmax operator +C<< infix:<minmax> >>, the minmax operator $min0, $max0 minmax $min1, $max1 # ($min0 min $min1, $max0 max $max1) @@ -1226,7 +1248,7 @@ =item * -infix:<X>, the cross operator +C<< infix:<X> >>, the cross operator 1,2 X 3,4 # (1,3), (1,4), (2,3), (2,4) @@ -1269,7 +1291,7 @@ =item * -infix:<=>, list assignment +C<< infix:<=> >>, list assignment @array = 1,2,3; @@ -1291,7 +1313,7 @@ =item * -infix:<:>, the invocant marker +C<< infix:<:> >>, the invocant marker say $*OUT: "howdy, world" @@ -1435,7 +1457,7 @@ =item * -infix:<and>, short-circuit and +C<< infix:<and> >>, short-circuit and $condition and $whentrue @@ -1452,7 +1474,7 @@ =item * -infix:<or>, short-circuit inclusive or +C<< infix:<or> >>, short-circuit inclusive or $condition or $whenfalse @@ -1462,7 +1484,7 @@ =item * -infix:<xor>, exclusive or +C<< infix:<xor> >>, exclusive or $x xor $y @@ -1473,7 +1495,7 @@ =item * -infix:<err>, short-circuit defined-or +C<< infix:<err> >>, short-circuit defined-or $value err $default @@ -1579,10 +1601,17 @@ PerlĀ 5's C<${...}>, C<@{...}>, C<%{...}>, etc. dereferencing forms are now C<$(...)>, C<@(...)>, C<%(...)>, etc. instead. Listop-like forms use the bare sigil following by whitespace. +Use of the Perl 5 curly forms will result in an error message +pointing the user to the new forms. =item * -C<< -> >> becomes C<.>, like the rest of the world uses. +C<< -> >> becomes C<.>, like the rest of the world uses. There is +a pseudo C<< postfix:{'->'} >> operator that produces a compile-time +error reminding Perl 5 users to use dot instead. (The "pointy block" +use of C<< -> >> in Perl 5 requires preceding whitespace when the arrow +could be confused with a postfix, that is when an infix is expected. +Preceding whitespace is not required in term position.) =item * @@ -1652,6 +1681,10 @@ Note that C<:s> still returns the filesize, but C<:!s> is true only if the file is of size 0. +(Inadvertent use of the Perl 5 forms will normally result in treatment +as a negated postdeclared subroutine, which is likely to produce an +error message at the end of compilation.) + =item * All postfix operators that do not start with a dot also have @@ -1717,7 +1750,8 @@ =item * -The C<? :> conditional operator becomes C<?? !!>. +The C<? :> conditional operator becomes C<?? !!>. A pseudo operator, +C<< infix:<?> >>, catches migratory brainos at compile time. =item * @@ -1730,6 +1764,9 @@ In item context comma C<,> now constructs a C<List> object from its operands. You have to use a C<[*-1]> subscript to get the last one. +(Note the C<*>. Negative subscripts no longer implicitly count from +the end; in fact, the compiler may complain if you use C<[-1]> on an +object known at compile time not to have negative subscripts.) =item * @@ -3099,6 +3136,8 @@ [^]() # one() [!==]() # Bool::False (also for 1 arg) [==]() # Bool::True (also for 1 arg) + [before]() # Bool::True (also for 1 arg) + [after]() # Bool::True (also for 1 arg) [<]() # Bool::True (also for 1 arg) [<=]() # Bool::True (also for 1 arg) [>]() # Bool::True (also for 1 arg) Modified: doc/trunk/design/syn/S12.pod ============================================================================== --- doc/trunk/design/syn/S12.pod (original) +++ doc/trunk/design/syn/S12.pod Fri Jun 15 12:10:26 2007 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 27 Oct 2004 - Last Modified: 31 May 2007 + Last Modified: 15 May 2007 Number: 12 - Version: 54 + Version: 55 =head1 Overview @@ -225,6 +225,16 @@ $obj."$methodname"(1,2,3) # use contents of $methodname as method name $obj.'$methodname'(1,2,3) # no interpolation; call method with $ in name! +[Note: to help catch the mistaken use of C<< infix:<.> >> as a string +concatenation operator, Perl 6 will warn you about "useless use of +quotes" at compile time if the string inside quotes is an identifier. +(It does not warn about non-identifier strings, but such strings are +likely to produce missing method errors at run time in any case.) +Also, if there is whitespace around an intended C<.> concatenation, +it cannot be parsed as a method call at all; instead if fails at +compile time because standard Perl 6 has no C<< infix:<.> >> operator +unless the user happens to have defined one (bad idea).] + For situations where you already have a method located, you can use a simple scalar variable in place of method name: