On Thu, Oct 25, 2001 at 10:42:15AM -0700, Glenn Linderman wrote:

> So then the lexically scoped operator:+ wouldn't be able to achieve
> the goal of my suggested implicit numerification warning... the goal
> being the ability to ensure that there are no implicit numerifications,
> that all numerifications are done via a selected conversion methed.

That's fine, though. You've already got the warning in perl5:

     /* from Perl_sv_2nv in sv.c */
     if (SvPOKp(sv) && SvLEN(sv)) {
         if (ckWARN(WARN_NUMERIC) && !SvIOKp(sv) && !looks_like_number(sv))
             not_a_number(sv);
         return Atof(SvPVX(sv));
     }

So, you don't need operator:+ to do it.

     % perl -wle '$x="x";print sprintf("%d",$x), abs($x)'
     Argument "x" isn't numeric in sprintf at -e line 1.
     00

Note that once the conversion to number has happened once, it's cached,
and you won't see the warning again. This may or may not meet your
criteria....

If you want to warn on conversions even if the number looked numeric, you
could simply add another warning type (e.g. WARN_VERBOSE_NUMERIC) and
then have:

     if (SvPOKp(sv) && SvLEN(sv)) {
         if (ckWARN(WARN_NUMERIC) && !SvIOKp(sv) && 
             (ckWARN(WARN_VERBOSE_NUMERIC) || !looks_like_number(sv)))
             not_a_number(sv);
         return Atof(SvPVX(sv));
     }


-- 
Aaron Sherman
[EMAIL PROTECTED]             finger [EMAIL PROTECTED] for GPG info. Fingerprint:
www.ajs.com/~ajs        6DC1 F67A B9FB 2FBA D04C  619E FC35 5713 2676 CEAF
"Write your letters in the sand for the day I'll take your hand
In the land that our grandchildren knew." -Queen/_'39_

Reply via email to