You know, hidden away in all the pointless hieroglyphics, verbose irrelevancies, overly complicated example, and cutesy catch phrases, there is actually the glimmer of an arguable point:
the language-system “raised no ‘quibble’ at all.”
Isolated and translated, if you'd said: "Perl doesn't raise a warning when you use a reference in a numeric context; and that has caught me out.", then you might at least have engendered some reasonable discussion on a potentially valid point.
And so, just for you, here it is:
C:\test\perl-5.18.0>.\perl -E"say 0+$_ for \( 1, 'fred', $^O, @a, %h)"
Reference used in a numeric context at -e line 1.
10473656
Reference used in a numeric context at -e line 1.
10474016
Reference used in a numeric context at -e line 1.
10845904
Reference used in a numeric context at -e line 1.
10845952
Reference used in a numeric context at -e line 1.
10848256
Now that needs work. If the reference is held in a variable (as opposed to being use anonymously print \$s + 0;), it'd be nice to list which variable. And the exact text would probably need world+dog approval, along with its warning category; but it could be argued for.
And the change required to make that possible: C:\test\perl-5.18.0>diff -u sv.c sv.c.modified
--- sv.c Wed Dec 10 02:32:20 2014
+++ sv.c.modified Wed Dec 10 02:13:15 2014
@@ -2682,6 +2682,7 @@
if (tmpsv && (!SvROK(tmpsv) || (SvRV(tmpsv) != SvRV(sv))))
return sv_2num(tmpsv);
}
+ Perl_warner(aTHX_ packWARN(WARN_NUMERIC), "Reference used in a
+ numeric context" );
return sv_2mortal(newSVuv(PTR2UV(SvRV(sv))));
}
That's right. A single added line. (Feel free to take that to p5p and champion it.)
Of course, that raises the question, why if it is so easy to implement, hasn't it been done before? The most likely answer to which is: because no one has found it to be necessary. Till now...?
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|