[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
Re: exists &sub (was: exists $foo[7] and delete $foo[7])
On Wed, 19 Jan 2000 11:03:18 -0500, Ronald J Kimball wrote (in part):
rjk> One little typo...
Good catch. Thanks. The attached fixes that, along with an improper bogus
error once other errors have already been seen.
Specifically,
sub foo {1;}
undef foo; # note missing & on foo
exists &foo;
This example would correctly report the improper use of &foo as
an lvalue, but would then go on to complain that the argument to
exists is not a subroutine name. The patch below makes it err in
the other direction, so that now this example:
sub foo {1;}
undef foo; # note missing & on foo
exists &foo();
will be silent about the second error. This 'feels' better than
generating the bogus error on the correct construct as in the
first example.
--s.
--- ./pod/perlfunc.pod.PREV Wed Jan 19 11:40:52 2000
+++ ./pod/perlfunc.pod Wed Jan 19 11:43:23 2000
@@ -1423,7 +1423,7 @@ A hash or array element can be true only
it exists, but the reverse doesn't necessarily hold true.
Given an expression that specifies the name of a subroutine,
-returns true of the specified subroutine has ever been declared, even
+returns true if the specified subroutine has ever been declared, even
if it is undefined. Mentioning a subroutine name for exists or defined
does not count as declaring it.
--- ./op.c.PREV Wed Jan 19 11:40:53 2000
+++ ./op.c Wed Jan 19 11:42:31 2000
@@ -5035,7 +5035,7 @@ Perl_ck_exists(pTHX_ OP *o)
OP *kid = cUNOPo->op_first;
if (kid->op_type == OP_ENTERSUB) {
(void) ref(kid, o->op_type);
- if (kid->op_type != OP_RV2CV)
+ if (kid->op_type != OP_RV2CV && !PL_error_count)
Perl_croak(aTHX_ "%s argument is not a subroutine name",
PL_op_desc[o->op_type]);
o->op_private |= OPpEXISTS_SUB;
- References to:
-
Larry Wall <larry@wall.org>
spider-perl@Orb.Nashua.NH.US
Ronald J Kimball <rjk@linguist.dartmouth.edu>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]