From: Gurusamy Sarathy Date: Sun, 4 Jul 1999 02:38:34 +0000 (+0000) Subject: remove misleading info on defined(&func), unclutter deprecation X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f10b034643f35a8ac5fe5ed0513218d385884cbb;p=p5sagit%2Fp5-mst-13.2.git remove misleading info on defined(&func), unclutter deprecation about defined(@array) p4raw-id: //depot/perl@3567 --- diff --git a/op.c b/op.c index 3d07000..f0cd15f 100644 --- a/op.c +++ b/op.c @@ -4999,14 +4999,14 @@ Perl_ck_defined(pTHX_ OP *o) /* 19990527 MJD */ case OP_PADAV: case OP_AASSIGN: /* Is this a good idea? */ Perl_warner(aTHX_ WARN_DEPRECATED, - "defined(@array) is deprecated (and not really meaningful)"); + "defined(@array) is deprecated"); Perl_warner(aTHX_ WARN_DEPRECATED, "(Maybe you should just omit the defined()?)\n"); break; case OP_RV2HV: case OP_PADHV: Perl_warner(aTHX_ WARN_DEPRECATED, - "defined(%hash) is deprecated (and not really meaningful)"); + "defined(%hash) is deprecated"); Perl_warner(aTHX_ WARN_DEPRECATED, "(Maybe you should just omit the defined()?)\n"); break; diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 3f2214a..3284cf7 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -477,13 +477,13 @@ by Perl. (W) You used the C or C construction, but the command was missing or blank. -=item defined(@array) is deprecated (and not really meaningful) +=item defined(@array) is deprecated (D) defined() is not usually useful on arrays because it checks for an undefined I value. If you want to see if the array is empty, just use C for example. -=item defined(%hash) is deprecated (and not really meaningful) +=item defined(%hash) is deprecated (D) defined() is not usually useful on hashes because it checks for an undefined I value. If you want to see if the hash is empty, diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 0084f9c..d7b9024 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -1105,13 +1105,13 @@ times more than it has returned. This probably indicates an infinite recursion, unless you're writing strange benchmark programs, in which case it indicates something else. -=item defined(@array) is deprecated (and not really meaningful) +=item defined(@array) is deprecated (D) defined() is not usually useful on arrays because it checks for an undefined I value. If you want to see if the array is empty, just use C for example. -=item defined(%hash) is deprecated (and not really meaningful) +=item defined(%hash) is deprecated (D) defined() is not usually useful on hashes because it checks for an undefined I value. If you want to see if the hash is empty, diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 0ac2810..6b0fd9d 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -881,10 +881,17 @@ doesn't I indicate an exceptional condition: C returns C when its argument is an empty array, I when the element to return happens to be C. -You may also use C to check whether a subroutine exists, by -saying C without parentheses. On the other hand, use -of C upon aggregates (hashes and arrays) is not guaranteed to -produce intuitive results, and should probably be avoided. +You may also use C to check whether subroutine C<&func> +has ever been defined. The return value is unaffected by any forward +declarations of C<&foo>. + +Use of C on aggregates (hashes and arrays) is deprecated. It +used to report whether memory for that aggregate has ever been +allocated. This behavior may disappear in future versions of Perl. +You should instead use a simple test for size: + + if (@an_array) { print "has array elements\n" } + if (%a_hash) { print "has hash members\n" } When used on a hash element, it tells you whether the value is defined, not whether the key exists in the hash. Use L for the latter @@ -914,14 +921,6 @@ should use C only when you're questioning the integrity of what you're trying to do. At other times, a simple comparison to C<0> or C<""> is what you want. -Use of C on aggregates (hashes and arrays) is deprecated. It -used to report whether memory for that aggregate has ever been -allocated. This behavior may disappear in future versions of Perl. -You should instead use a simple test for size: - - if (@an_array) { print "has array elements\n" } - if (%a_hash) { print "has hash members\n" } - See also L, L, L. =item delete EXPR diff --git a/t/pragma/warn/op b/t/pragma/warn/op index c72534a..a07a837 100644 --- a/t/pragma/warn/op +++ b/t/pragma/warn/op @@ -87,13 +87,13 @@ (Maybe you meant system() when you said exec()? exec "true" ; my $a - defined(@array) is deprecated (and not really meaningful) + defined(@array) is deprecated (Maybe you should just omit the defined()?) defined @a ; my @a ; defined @a ; defined (@a = (1,2,3)) ; - defined(%hash) is deprecated (and not really meaningful) + defined(%hash) is deprecated (Maybe you should just omit the defined()?) defined %h ; my %h ; defined %h ; @@ -558,33 +558,33 @@ Statement unlikely to be reached at - line 4. use warning 'deprecated' ; defined(@a); EXPECT -defined(@array) is deprecated (and not really meaningful) at - line 3. +defined(@array) is deprecated at - line 3. (Maybe you should just omit the defined()?) ######## # op.c use warning 'deprecated' ; my @a; defined(@a); EXPECT -defined(@array) is deprecated (and not really meaningful) at - line 3. +defined(@array) is deprecated at - line 3. (Maybe you should just omit the defined()?) ######## # op.c use warning 'deprecated' ; defined(@a = (1,2,3)); EXPECT -defined(@array) is deprecated (and not really meaningful) at - line 3. +defined(@array) is deprecated at - line 3. (Maybe you should just omit the defined()?) ######## # op.c use warning 'deprecated' ; defined(%h); EXPECT -defined(%hash) is deprecated (and not really meaningful) at - line 3. +defined(%hash) is deprecated at - line 3. (Maybe you should just omit the defined()?) ######## # op.c use warning 'deprecated' ; my %h; defined(%h); EXPECT -defined(%hash) is deprecated (and not really meaningful) at - line 3. +defined(%hash) is deprecated at - line 3. (Maybe you should just omit the defined()?)