Question (short version): Should a function, which requires numerical arguments, validate its inputs? If so, how?Answer (short version): I would want your function to validate my inputs. Most of the time, I want to know ASAP if I have fed the wrong type of thing to a function.
I can understand your arguments both for and against it. Unless it's a matter of performace (speed), validating is a good thing.
Again, most of the time, Perl has a knack for Doing The Right Thing. But, on occasion, I have wasted time debugging some code which was too forgiving.
Scalar::Util::looks_like_number can be used to validate floating-point inputs (I used it in my module).
In reply to Re: Parameter validation for numeric function arguments?
by toolic
in thread Parameter validation for numeric function arguments?
by janert
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |