:)

I'd be willing to bet this particular feature won't bite you again.

This is a good point to note how useful test first development is.

http://perlunit.sourceforge.net

If you start with the test/validation before even writing the code,
you'll seldom have an issue with this in production.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
John Deighan
Sent: Tuesday, October 17, 2006 9:13 AM
To: perl-win32-users@listserv.ActiveState.com
Subject: RE: what?!?

At 09:37 AM 10/17/2006, George Gallen wrote:
>Referencing the last element of an array (-1) without having to get
>the # of elements first, is VERY useful. Using other negative positions
>might not have as many uses, but when you find one, You'll be glad
>it's there.

The problem comes when you have a function that computes an index, 
it's buggy and returns a negative number. Using that index returns 
incorrect data instead of an undefined value, which makes it much 
harder to detect that bug. Besides, what's so hard about 
saying  [EMAIL PROTECTED]  as opposed to  $array[-1]  ?

>As for bounds checking, that always (well almost always) needs to be
>done by the routine for two reasons. the first is that you don't want
>the system to throw out warnings and/or error messages while the
program
>is running (it scares the user), and secondly, you never know what the
>user will enter as a reference number for an array position.

You can trap errors and warnings. We usually inform the user that 
something went wrong, but send a detailed error message via an e-mail 
to ourselves. I think that most users would rather be told that 
something went wrong than to get incorrect data. Incorrect data that 
is taken as correct data can lead to very bad things.

Lack of automatic bounds checking (at least in cases where the 
boundaries are fixed, so this doesn't really relate to Perl) is 
responsible for all the "buffer overflow" security holes we find 
outselves having to deal with.

I totally agree that all data entered by users needs to be thoroughly 
checked, but that's a different issue than whether we programmers 
should have to implement bounds checking for every time we index into an
array.

>As they say, no program is fool proof, because fools can be so
ingenious,
>but the more boundry checking you have with inputs and such, then you
>it gives you more of chance to tell the user what a fool they are....
>
>George
>
> > it's in the docs. Also, I checked, and if you index past the
> > beginning of an array with a negative number, you get undef, which
is
> > at least consistent with what happens when you index past the far
end
> > of an array.
> >
>
>
>Scanned for Spam and Viruses.
>PCG Information Technology Services.

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to