diff options
author | Zefram <zefram@fysh.org> | 2011-09-09 23:27:16 +0100 |
---|---|---|
committer | Zefram <zefram@fysh.org> | 2011-09-09 23:30:02 +0100 |
commit | e1dccc0d34a90e3511bfed596be9d78128ca7ee7 (patch) | |
tree | 1e72ad2098f66ac1c59debfc46c00d1013fc0a9f /pod | |
parent | 0b31f5359876e6c0b203006714db218d7b441cd1 (diff) | |
download | perl-e1dccc0d34a90e3511bfed596be9d78128ca7ee7.tar.gz |
remove index offsetting ($[)
$[ remains as a variable. It no longer has compile-time magic.
At runtime, it always reads as zero, accepts a write of zero, but dies
on writing any other value.
Diffstat (limited to 'pod')
-rw-r--r-- | pod/perldata.pod | 8 | ||||
-rw-r--r-- | pod/perldelta.pod | 10 | ||||
-rw-r--r-- | pod/perldiag.pod | 25 | ||||
-rw-r--r-- | pod/perlfunc.pod | 10 | ||||
-rw-r--r-- | pod/perlvar.pod | 24 |
5 files changed, 27 insertions, 50 deletions
diff --git a/pod/perldata.pod b/pod/perldata.pod index f34979cef1..6d0fa0b21f 100644 --- a/pod/perldata.pod +++ b/pod/perldata.pod @@ -251,14 +251,6 @@ which return whatever they feel like returning.) The following is always true: X<array, length> - scalar(@whatever) == $#whatever - $[ + 1; - -Version 5 of Perl changed the semantics of C<$[>: files that don't set -the value of C<$[> no longer need to worry about whether another -file changed its value. (In other words, use of C<$[> is deprecated.) -So in general you can assume that -X<$[> - scalar(@whatever) == $#whatever + 1; Some programmers choose to use an explicit conversion so as to diff --git a/pod/perldelta.pod b/pod/perldelta.pod index bd03c83b39..b44c8440b6 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -60,6 +60,16 @@ pointers to null. Bug reported by Clément Lecigne. =head1 Incompatible Changes +=head2 $[ has been removed + +The array/string index offsetting mechanism, controlled by the C<$[> magic +variable, has been removed. C<$[> now always reads as zero. Writing a +zero to it is still permitted, but writing a non-zero value causes an +exception. Those hopelessly addicted to FORTRAN-style 1-based indexing +may wish to use the module L<Array::Base>, which provides an independent +implementation of the index offsetting concept, or L<Classic::Perl>, +which allows L<Array::Base> to be controlled through assignment to C<$[>. + =head2 User-defined case changing operations. This feature was deprecated in Perl 5.14, and has now been removed. diff --git a/pod/perldiag.pod b/pod/perldiag.pod index d4373d6b3a..9ef46e4e36 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -238,6 +238,11 @@ spots. This is now heavily deprecated. (P) A general assertion failed. The file in question must be examined. +=item Assigning non-zero to $[ is no longer possible + +(F) The special variable C<$[>, deprecated in older perls, is now a fixed +zero value, because the feature that it used to control has been removed. + =item Assignment to both a list and a scalar (F) If you assign to a conditional operator, the 2nd and 3rd arguments @@ -4504,21 +4509,6 @@ a dirhandle. Check your control flow. (W unopened) You tried to use the tell() function on a filehandle that was either never opened or has since been closed. -=item That use of $[ is unsupported - -(F) Assignment to C<$[> is now strictly circumscribed, and interpreted -as a compiler directive. You may say only one of - - $[ = 0; - $[ = 1; - ... - local $[ = 0; - local $[ = 1; - ... - -This is to prevent the problem of one module changing the array base out -from under another module inadvertently. See L<perlvar/$[>. - =item The crypt() function is unimplemented due to excessive paranoia (F) Configure couldn't find the crypt() function on your machine, @@ -5119,11 +5109,6 @@ you can write it as C<push(@tied_array,())> to avoid this warning. (F) The "use" keyword is recognized and executed at compile time, and returns no useful value. See L<perlmod>. -=item Use of assignment to $[ is deprecated - -(D deprecated) The C<$[> variable (index of the first element in an array) -is deprecated. See L<perlvar/"$[">. - =item Use of bare << to mean <<"" is deprecated (D deprecated) You are now encouraged to use the explicitly quoted diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 7799fe4606..981032be05 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -2683,9 +2683,8 @@ It returns the position of the first occurrence of SUBSTR in STR at or after POSITION. If POSITION is omitted, starts searching from the beginning of the string. POSITION before the beginning of the string or after its end is treated as if it were the beginning or the end, -respectively. POSITION and the return value are based at C<0> (or whatever -you've set the C<$[> variable to--but don't do that). If the substring -is not found, C<index> returns one less than the base, ordinarily C<-1>. +respectively. POSITION and the return value are based at zero. +If the substring is not found, C<index> returns -1. =item int EXPR X<int> X<integer> X<truncate> X<trunc> X<floor> @@ -6059,7 +6058,7 @@ If both OFFSET and LENGTH are omitted, removes everything. If OFFSET is past the end of the array, Perl issues a warning, and splices at the end of the array. -The following equivalences hold (assuming C<< $[ == 0 and $#a >= $i >> ) +The following equivalences hold (assuming C<< $#a >= $i >> ) push(@a,$x,$y) splice(@a,@a,0,$x,$y) pop(@a) splice(@a,-1) @@ -6866,8 +6865,7 @@ X<substr> X<substring> X<mid> X<left> X<right> =item substr EXPR,OFFSET Extracts a substring out of EXPR and returns it. First character is at -offset C<0> (or whatever you've set C<$[> to (but B<don't do that>)). -If OFFSET is negative (or more precisely, less than C<$[>), starts +offset zero. If OFFSET is negative, starts that far back from the end of the string. If LENGTH is omitted, returns everything through the end of the string. If LENGTH is negative, leaves that many characters off the end of the string. diff --git a/pod/perlvar.pod b/pod/perlvar.pod index 890909d526..3217e3cc55 100644 --- a/pod/perlvar.pod +++ b/pod/perlvar.pod @@ -2071,25 +2071,17 @@ Removed in Perl 5.10. =item $[ X<$[> X<$ARRAY_BASE> -This variable stores the index of the first element in an array, and -of the first character in a substring. The default is 0, but you could -theoretically set it to 1 to make Perl behave more like B<awk> (or Fortran) -when subscripting and when evaluating the index() and substr() functions. - -As of release 5 of Perl, assignment to C<$[> is treated as a compiler -directive, and cannot influence the behavior of any other file. -(That's why you can only assign compile-time constants to it.) -Its use is highly discouraged. - -Prior to Perl 5.10, assignment to C<$[> could be seen from outer lexical -scopes in the same file, unlike other compile-time directives (such as -L<strict>). Using local() on it would bind its value strictly to a lexical -block. Now it is always lexically scoped. - -Mnemonic: [ begins subscripts. +C<$[> was a variable that you could use to offset the indexing of arrays +and strings. After a deprecation cycle, the feature was removed in +Perl 5.16. Two old ways of coping with the variability of the index +offset, which were rendered obsolete in Perl 5.000 when C<$[> became +effectively lexically scoped, are still supported: you can read it +(always yielding zero) and you can assign zero to it. Deprecated in Perl 5.12. +Removed in Perl 5.16. + =item $OLD_PERL_VERSION =item $] |