in reply to Re^3: "Useless use of a constant" in grep block?
in thread "Useless use of a constant" in grep block?
When something is (indeed) a warning, there's always the possibility that the warning is incorrect in that it does not align with what the user means. But this alone does not invalidate the fact said warning is useful. For example, using another warning that has "possibly" in its wording:
% perl -Mstrict -MFoo -we'$Foo::bar = 1' Name "Foo::bar" used only once: possible typo at -e line 1.
Does the programmer make a typo or does he really mean setting $Foo::bar? perl can never know for sure, so it just emits a warning instead of an error message. The programmer can disable the warning if he knows that he is doing what he wants. Continuing with another warning which you mentioned:
our @EXPORT = qw( foo bar baz qux quux );
and a few months later:
our @EXPORT = qw( foo bar baz qux quux corge grault # not sure we want to export these by default because the name is +rather common, # but let's do it anyways for now thud jet );
Are you sure that you, even if you're already a veteran, will never make this mistake? perl is being helpful here by emitting a warning. If perl turns out to be wrong here, just disable the warning lexically.
But I guess there's always the debate of how much should perl offer helping hands and treat the programmer like a novice or stupid person. But hey, humans *are* stupid :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: "Useless use of a constant" in grep block?
by Anonymous Monk on Aug 04, 2017 at 10:14 UTC | |
|
Re^5: "Useless use of a constant" in grep block?
by Anonymous Monk on Aug 03, 2017 at 12:00 UTC |