Author: lwall Date: 2009-04-19 20:19:50 +0200 (Sun, 19 Apr 2009) New Revision: 26292
Modified: docs/Perl6/Spec/S02-bits.pod docs/Perl6/Spec/S03-operators.pod docs/Perl6/Spec/S04-control.pod docs/Perl6/Spec/S05-regex.pod docs/Perl6/Spec/S07-iterators.pod docs/Perl6/Spec/S09-data.pod docs/Perl6/Spec/S16-io.pod docs/Perl6/Spec/S28-special-names.pod docs/Perl6/Spec/S32-setting-library/Str.pod Log: Kill prefix:<=> very, very dead. Modified: docs/Perl6/Spec/S02-bits.pod =================================================================== --- docs/Perl6/Spec/S02-bits.pod 2009-04-19 17:38:10 UTC (rev 26291) +++ docs/Perl6/Spec/S02-bits.pod 2009-04-19 18:19:50 UTC (rev 26292) @@ -12,9 +12,9 @@ Maintainer: Larry Wall <la...@wall.org> Date: 10 Aug 2004 - Last Modified: 10 Apr 2009 + Last Modified: 19 Apr 2009 Number: 2 - Version: 163 + Version: 164 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -2502,7 +2502,7 @@ you should use C<< ['a'] >> for clarity as well as correctness. The degenerate case C<< <> >> is disallowed as a probable attempt to -do IO in the style of Perl 5; that is now written C<< =<> >>. (C<< +do IO in the style of Perl 5; that is now written C<lines()>. (C<< <STDIN> >> is also disallowed.) Empty lists are better written with C<()> or C<Nil> in any case because C<< <> >> will often be misread as meaning C<('')>. (Likewise the subscript form C<< %foo<> >> @@ -3540,19 +3540,16 @@ =item * To force non-lazy list flattening, use the C<eager> list operator. -Don't use it on an infinite list unless you have a machine with -infinite memory, and are willing to wait a long time. To expand an -iterator object to completion, iterate it with C<< prefix:<=> >> -inside an eager list: +List assignment is also implicitly eager. - @lines = eager =$filehandle; # read all remaining lines + eager $filehandle.lines; # read all remaining lines By contrast, - @lines = =$filehandle; + $filehandle.lines; makes no guarantee about how many lines ahead the iterator has read. -Iterators appending to a list are allowed to process in batches, even +Iterators feeding a list are allowed to process in batches, even when stored within an array. The array knows that it is extensible, and calls the iterator as it needs more elements. (Counting the elements in the array will also force eager completion.) @@ -3651,21 +3648,12 @@ you now write - for =$handle {...} + for @$handle {...} -As a unary prefix operator, you may also apply adverbs to C<=>: - - for =$handle :prompt('$ ') { say $_ + 1 } - or - for =($handle):prompt('$ ') { say $_ + 1 } + for $handle.lines {...} -or you may even write it in its functional form, passing the adverbs -as ordinary named arguments. - - for prefix:<=>($handle, :prompt('$ ')) { say $_ + 1 } - =back =head1 Properties Modified: docs/Perl6/Spec/S03-operators.pod =================================================================== --- docs/Perl6/Spec/S03-operators.pod 2009-04-19 17:38:10 UTC (rev 26291) +++ docs/Perl6/Spec/S03-operators.pod 2009-04-19 18:19:50 UTC (rev 26292) @@ -12,9 +12,9 @@ Maintainer: Larry Wall <la...@wall.org> Date: 8 Mar 2004 - Last Modified: 10 Apr 2009 + Last Modified: 19 Apr 2009 Number: 3 - Version: 162 + Version: 163 =head1 Overview @@ -33,7 +33,7 @@ L Method postfix .meth .+ .? .* .() .[] .{} .<> .«» .:: .= .^ .: N Autoincrement ++ -- R Exponentiation ** - L Symbolic unary ! + - ~ ? | +^ ~^ ?^ ^ = + L Symbolic unary ! + - ~ ? | +^ ~^ ?^ ^ L Multiplicative * / % +& +< +> ~& ~< ~> ?& div mod L Additive + - +| +^ ~| ~^ ?| ?^ L Replication x xx @@ -678,28 +678,6 @@ Constructs a range of C<0 ..^ $limit> or locates a metaclass as a shortcut for C<$limit.HOW>. See L</Range semantics>. -=item * - -C<< prefix:<=> >>, iterate iterator - - =$iterator - -Unary C<=> reads lines from a filehandle or filename, or -iterates an iterator, or in general causes a scalar to explode its guts -when it would otherwise not. How it does that is context sensitive. -For instance, C<=$iterator> is item/list context sensitive and will -produce one value in item context but many values in list context. -The production of values is abstract here, so a lazy list merely -remembers that it should iterate the iterator to completion upon -demand. Use an eager list to force completion. - -Use C<@$iterator> to produce a list of all the values even in item -context, and C<$$iterator> to produce a single value even -in list context. On the other hand, C<=$capture> produces all -parts of the capture that makes sense in the current list context, -depending on what controls that list context. [Conjecture: the -previous sentence is non-sensical.] - =back =head2 Multiplicative precedence Modified: docs/Perl6/Spec/S04-control.pod =================================================================== --- docs/Perl6/Spec/S04-control.pod 2009-04-19 17:38:10 UTC (rev 26291) +++ docs/Perl6/Spec/S04-control.pod 2009-04-19 18:19:50 UTC (rev 26292) @@ -12,9 +12,9 @@ Maintainer: Larry Wall <la...@wall.org> Date: 19 Aug 2004 - Last Modified: 17 Apr 2009 + Last Modified: 19 Apr 2009 Number: 4 - Version: 75 + Version: 76 This document summarizes Apocalypse 4, which covers the block and statement syntax of Perl. @@ -435,18 +435,20 @@ while (my $line = <STDIN>) {...} -in Perl 6 you should use a C<for> (plus a unary C<=> "iterate the -iterator" operator) instead: +in Perl 6 you should use a C<for> instead: - for =$*IN -> $line {...} + for $*IN.lines -> $line {...} This has the added benefit of limiting the scope of the C<$line> parameter to the block it's bound to. (The C<while>'s declaration of C<$line> continues to be visible past the end of the block. Remember, no implicit block scopes.) It is also possible to write - while =$*IN -> $line {...} + while $*IN.get -> $line {...} +However, this is likely to fail on autochomped filehandles, so use +the C<for> loop instead. + Note also that Perl 5's special rule causing while (<>) {...} @@ -454,11 +456,11 @@ to automatically assign to C<$_> is not carried over to Perl 6. That should now be written: - for =<> {...} + for lines() {...} which is short for - for =$*ARGFILES {...} + for lines($*ARGFILES) {...} Arguments bound to the formal parameters of a pointy block are by default readonly within the block. You can declare a parameter Modified: docs/Perl6/Spec/S05-regex.pod =================================================================== --- docs/Perl6/Spec/S05-regex.pod 2009-04-19 17:38:10 UTC (rev 26291) +++ docs/Perl6/Spec/S05-regex.pod 2009-04-19 18:19:50 UTC (rev 26292) @@ -14,9 +14,9 @@ Maintainer: Patrick Michaud <pmich...@pobox.com> and Larry Wall <la...@wall.org> Date: 24 Jun 2002 - Last Modified: 22 Mar 2009 + Last Modified: 19 Mar 2009 Number: 5 - Version: 94 + Version: 95 This document summarizes Apocalypse 5, which is about the new regex syntax. We now try to call them I<regex> rather than "regular @@ -4041,7 +4041,7 @@ Anything that can be tied to a string can be matched against a regex. This feature is particularly useful with input streams: - my $stream := cat =$fh; # tie scalar to filehandle + my $stream := cat $fh.lines; # tie scalar to filehandle # and later... Modified: docs/Perl6/Spec/S07-iterators.pod =================================================================== --- docs/Perl6/Spec/S07-iterators.pod 2009-04-19 17:38:10 UTC (rev 26291) +++ docs/Perl6/Spec/S07-iterators.pod 2009-04-19 18:19:50 UTC (rev 26292) @@ -10,8 +10,8 @@ Contributions: Tim Nelson <wayl...@wayland.id.au> Daniel Ruoso <dan...@ruoso.com> Date: 27 Nov 2008 - Last Modified: 28 Dec 2008 - Version: 3 + Last Modified: 19 Apr 2008 + Version: 4 =head1 Laziness and Eagerness @@ -193,21 +193,16 @@ You can later do: - my $item = =$it; + my $item = $it.get; + my @items = @$it; -Or if the double '=' bothers you in front: - - my $item2 = $it.:<=>; - -(XXX TODO: decide whether the item iterator flattens, document) - (XXX TODO: effect of type constraints of $it -- maybe to control flattening? ) (XXX TODO: What's this do? - my $it <== @a; my $it2 <== $it; my $it3 <== $it; =$it2; =$it3; + my $it <== @a; my $it2 <== $it; my $it3 <== $it; get $it2; get $it3; ...allow tag team suckling? @@ -337,11 +332,11 @@ my @a = (1); my $it; $it <== my_coro() <== while 1 { shift(@a) }; - say "First result: " ~ =$it; + say "First result: " ~ get $it; @a.push("Hello World"); - say "Second result: " ~ =$it; + say "Second result: " ~ get $it; @a.push(500); - say "Third result: " ~ =$it; + say "Third result: " ~ get $it; ...if you want to pass multiple parameters on each call, you can use a slice slurpy instead, to pass a C<Capture>. @@ -358,7 +353,7 @@ } method corocall($message) { @!data.push($message); - =$!it; + get $!it; } } my $c = my_sub2coro.new(coro => &my_coro); Modified: docs/Perl6/Spec/S09-data.pod =================================================================== --- docs/Perl6/Spec/S09-data.pod 2009-04-19 17:38:10 UTC (rev 26291) +++ docs/Perl6/Spec/S09-data.pod 2009-04-19 18:19:50 UTC (rev 26292) @@ -360,7 +360,7 @@ my @@x; @@x <== %hash.keys.grep: {/^\d+$/}; - @@x <== =<>; + @@x <== lines; @@x <== 1..*; @@x <== gather { loop { take 100.rand } }; @@ -372,7 +372,7 @@ my @x; @x <== %hash.keys.grep: {/^\d+$/}; - @x <== =<>; + @x <== lines; @x <== 1..*; @x <== gather { loop { take 100.rand } }; Modified: docs/Perl6/Spec/S16-io.pod =================================================================== --- docs/Perl6/Spec/S16-io.pod 2009-04-19 17:38:10 UTC (rev 26291) +++ docs/Perl6/Spec/S16-io.pod 2009-04-19 18:19:50 UTC (rev 26292) @@ -12,8 +12,8 @@ Tim Nelson <wayl...@wayland.id.au> Daniel Ruoso <dan...@ruoso.com> Date: 12 Sep 2006 - Last Modified: 23 Feb 2009 - Version: 21 + Last Modified: 19 Apr 2009 + Version: 22 This is a draft document. Many of these functions will work as in Perl 5, except we're trying to rationalize everything into roles. For @@ -41,8 +41,9 @@ When no explicit filehandle is used, the standard IO operators are defined in terms of the contextual variables. So the C<print> function -prints to C<$*OUT>, while C<warn> warns to C<$*ERR>. The C<< =<> >> -term inputs from C<$*IN>. So any given dynamic scope (interpreter, +prints to C<$*OUT>, while C<warn> warns to C<$*ERR>. The C<< lines() >> +term inputs from C<$*ARGFILES> which defaults to C<$*IN> in the absence of any +filenames. So any given dynamic scope (interpreter, thread, function or method call) may redefine the current meaning of any of those filehandles within the dynamic scope of itself and of its called routines. Modified: docs/Perl6/Spec/S28-special-names.pod =================================================================== --- docs/Perl6/Spec/S28-special-names.pod 2009-04-19 17:38:10 UTC (rev 26291) +++ docs/Perl6/Spec/S28-special-names.pod 2009-04-19 18:19:50 UTC (rev 26292) @@ -10,7 +10,7 @@ Lyle Hopkins <webmas...@cosmicperl.com> Date: 23 Feb 2009, created by Tim Nelson from miscellaneous documents lying around Last Modified: 19 Apr 2009 - Version: 5 + Version: 6 =head1 Special Variables @@ -201,8 +201,8 @@ $^W $*WARNINGS (if any dynamic control needed) ${^WARNING_BITS} $?WARNINGS $^X $*EXECUTABLE_NAME ...or some such - ARGV $*ARGS Note the P6 idiom for this handle: - for =$*ARGS { + ARGV $*ARGFILE Note the P6 idiom for this handle: + for lines() { # each time through loop # proc a line from files named in ARGS } Modified: docs/Perl6/Spec/S32-setting-library/Str.pod =================================================================== --- docs/Perl6/Spec/S32-setting-library/Str.pod 2009-04-19 17:38:10 UTC (rev 26291) +++ docs/Perl6/Spec/S32-setting-library/Str.pod 2009-04-19 18:19:50 UTC (rev 26292) @@ -349,7 +349,7 @@ =item comb - our List multi comb ( Regex $matcher = /\S+/, Str $input, Int $limit = * ) + our List multi comb ( Regex $matcher, Str $input, Int $limit = * ) our List multi method comb ( Str $input: Regex $matcher = /\S+/, Int $limit = * ) The C<comb> function looks through a string for the interesting bits, @@ -454,7 +454,7 @@ sprintf "%d%C is %d digits long", $num, - sub($s,@args is rw) {...@args[2]=$s.elems}, + sub ($s, @args is rw) { @args[2] = $s.elems }, 0; The special directive, C<%n> does not work in Perl 6 because of the