Author: larry Date: Tue May 27 16:19:34 2008 New Revision: 14546 Modified: doc/trunk/design/syn/S09.pod
Log: Cleanup bogus use of adverbs on bare terms Modified: doc/trunk/design/syn/S09.pod ============================================================================== --- doc/trunk/design/syn/S09.pod (original) +++ doc/trunk/design/syn/S09.pod Tue May 27 16:19:34 2008 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 13 Sep 2004 - Last Modified: 2 Apr 2008 + Last Modified: 27 May 2008 Number: 9 - Version: 26 + Version: 27 =head1 Overview @@ -524,29 +524,21 @@ say @dwarves{1}; # Fails: can't map .{1} to a standard .[] index -When a C<:k>, C<:kv>, or C<:p> adverb is applied to a full array, -the keys returned are always the standard indices. - - my @arr{1,3,5,7,9} = <one two three four five>; - - say @arr:k; # 0, 1, 2, 3, 4 - -However, you can specify which set of keys are returned: - - say @arr:k[] # 0, 1, 2, 3, 4 - say @arr:k{} # 1, 3, 5, 7, 9 - When C<:k>, C<:kv>, or C<:p> is applied to an array slice, it returns -the kind of indices that were used to produce the slice, unless the type -of index is explicitly requested: +the kind of indices that were used to produce the slice: @arr[0..2]:p # 0=>'one', 1=>'two', 2=>'three' - @arr[0..2]:p[] # 0=>'one', 1=>'two', 2=>'three' - @arr[0..2]:p{} # 1=>'one', 3=>'two', 5=>'three' - @arr{1,3,5}:p # 1=>'one', 3=>'two', 5=>'three' - @arr{1,3,5}:p[] # 0=>'one', 1=>'two', 2=>'three' - @arr{1,3,5}:p{} # 1=>'one', 3=>'two', 5=>'three' + +Adverbs may be applied only to operators, not to terms, so C<:k>, +C<:kv>, and C<:p> may not be applied to a full array. However, you +may apply an adverb to a Zen slice, which can indicate which set of +keys are desired: + + my @arr{1,3,5,7,9} = <one two three four five>; + + say @arr[]:k; # 0, 1, 2, 3, 4 + say @arr{}:k; # 1, 3, 5, 7, 9 The C<.keys> method also returns the keys of all existing elements. For a multidimensional array each key is a list containing one value for @@ -588,7 +580,7 @@ say @results[*]; # Same as: say @results[0..49] say @results{*}; # Same as: say @results{1..100 :by(2)} -You can omit unallocated elements, either by using the :v adverb: +You can omit unallocated elements, either by using the C<:v> adverb: say @results[*]:v; # Same as: say @results[0..3] say @results{*}:v; # Same as: say @results{1,3,5,7} @@ -846,7 +838,7 @@ need to be, if ever. So a PDL implementation is free to steal the values from these ranges and "piddle" around with them: - @nums[$min..$max:by(3)] + @nums[$min..$max :by(3)] @nums[$min..$max] @nums[$min..*:by(3)] @nums[1..*:by(2)] # the odds