in reply to Warning messages about useless constants ignore '0's and '1's
Basically, if you use 0 and or 1 and, etc., Perl won't warn about the useless use of a constant.case OP_CONST: sv = cSVOPo_sv; if (cSVOPo->op_private & OPpCONST_STRICT) no_bareword_allowed(o); else { if (ckWARN(WARN_VOID)) { useless = "a constant"; /* don't warn on optimised away booleans, eg * use constant Foo, 5; Foo || print; */ if (cSVOPo->op_private & OPpCONST_SHORTCIRCUIT) useless = 0; /* the constants 0 and 1 are permitted as they are conventionally used as dummies in constructs like 1 while some_condition_with_side_effects; */ else if (SvNIOK(sv) && (SvNV(sv) == 0.0 || SvNV(sv) == 1.0)) useless = 0;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Warning messages about useless constants ignore '0's and '1's
by ysth (Canon) on May 11, 2004 at 03:53 UTC |