Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
In my eyes, the number argument is required and not passing it should throw an exception.

But you are still dodging my question.

The point is, what difference would it make to how you handle the situation -- in your calling code -- whereby your code passes a non-numeric value to be numerically formatted.

If instead of concentrating upon some wholly artificial and academic value judgement of what (in your opinion), the module should or should not do, and instead think about what action your code would take when this situation arises, then you'd probably arrive at the conclusion that there are only two possibilities:

  1. You prevent the situation by ensuring that it cannot happen.
  2. You log an error if it does.

If the values are coming in from an unreliable (external) source, then you should be checking that they comply with your input criteria at source, and rejecting them if they fail to so comply. If you have done that, then an additional check at some later point when you are using them -- for example, inside a round() function -- are completely redundant.

If however, the values are being generated internally by your code, then it again falls to you to ensure that your code cannot generate non-numeric values where numeric values are required. Expecting a library routine to check your values for you is ridiculous.

The bottom line is that if you call a library routine to round() a numeric value, it falls to you to ensure that you only pass it numeric values. Expecting every other user of that module to bear the cost of the redundant check, just so you can avoid performing that check when required, is selfish. You (should) know where and when (in your code) it is necessary to validate values.

Look up design by contract.

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.

In reply to Re^5: Math::Round::Var::round() takes no action when a number is not supplied by BrowserUk
in thread Math::Round::Var::round() takes no action when a number is not supplied by metaperl

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

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

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (4)
    As of 2020-10-29 01:04 GMT
    Find Nodes?
      Voting Booth?
      My favourite web site is:

      Results (265 votes). Check out past polls.