Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
But if definition of numeric was expanded to include more ambiguous num formats, then perl would need a new warning: treating "0x41" as numeric , might be wrong thing to do, silence with "no warnings q/extranumeric/;"

That's a (the first) plausible approach to the proposition. It is certainly doable; but at what benefit and what cost?

Ignoring for now the old saw of backward compatibility. (Though it certainly wouldn't be ignored by the only persons whom opinions matter in this regard, namely the denizens of p5p.)

The "benefit" would be that the programmer expecting non-decimal numbers in string input could write:

print "%d\n", $string;

Rather than:

printf "%d\n", hex( $string );

And the cost would be implicitly calling hex every time a scalar currently holding a PV, is used in a numeric context.

That doesn't seem such a bad thing. (At least if it had been that way since the beginning: Ba-w-d co-pa-bil-ty!)

But, either this is going to warn "might be wrong thing" every time it finds an extranumeric and the programmers who don't want that will have to disable it; or it will be silent and the programmers that do want the warning, will have to explicitly enable it.

Seems to me that for those few that do, something like this is just as easy:

sub myHex { no warnings 'digit'; hex( $_[0] }; } printf "%d\n", myHex( $string );

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". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^18: why are hex values not numbers? (octal) by BrowserUk
in thread why are hex values not numbers? by perl-diddler

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2022-12-07 19:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?