[aklug] Re: perl doesn't natively do booleans?????

From: Arthur Corliss <acorliss@nevaeh-linux.org>
Date: Wed Aug 18 2010 - 14:04:06 AKDT

On Wed, 18 Aug 2010, Michael Fowler wrote:

> If you're using it to verify your subroutine is getting the proper
> number of arguments, you're Doing it Wrong. Check @_ for that in the
> code. Prototypes are not for validation; using them for it will
> invariably trip someone up, either you, or someone using your code.

I strongly disagree. I'd rather have my code generate a compile-time error
than endure runtime errors because I forgot a mandatory argument. I
actually do both. I use prototypes *and* I check ref types, etc., as the
first order of business inside of a routine.

<snip>

> Prototypes also do not work on methods. This makes it especially
> frustrating trying to maintain code where the programmer thought they
> do, but the prototype has long since stopped matching what arguments the
> method is intended to receive. Trying to decipher if the prototype is
> documentation, out of sync, or the method is ever called as a function
> gets maddening.

So, in a nutshell you want to forbid *all* use of a tool just because it
doesn't work in all situations? That's taking dogmatic adherence to
programming philosophy a tad too far. If the tool works well in a
particular instance, I'm going to use it.

> I didn't overlook it, I simply didn't mention it. Whether or not the
> DNS lookup is relevant depends on what the input is.

Given that the specific use case asked for here was specifically to validate
*IP* addresses it more than begs a little for acknowledgement. It strongly
suggests that given bad input the program will not work as expected.

         --Arthur Corliss
           Live Free or Die
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Wed Aug 18 14:04:14 2010

This archive was generated by hypermail 2.1.8 : Wed Aug 18 2010 - 14:04:14 AKDT