Stewart Stremler wrote:

begin  quoting Christopher Smith as of Wed, Jun 07, 2006 at 09:17:45PM -0700:
[snip]
Actually, these kind of issues have been cropping up a fair bit in the C/C++ world. They've been cleaning out bugs like this from the GNU C core libraries for a number of years now. It's kind of disappointing that Java's core libraries have bugs like this in them, and more importantly that they are a "new" thing to the folks who wrote them.

I read the article and said "oh, yes, naturally, I've seen that in
several books and have had it pointed out in at least one class that
I took in school.
I guess you are more of an optimist than I am. If he learned about this because someone else recently reported it to Sun (implying that neither he nor anyone at Sun working on it subsequently had swept through the code to remove this), and he titled the article "Nearly All Binary Searches and Mergesorts Are Broken"... I dunnoh.

It shouldn't be "new". It should be a "d'oh!" moment.

Didn't languages like PL/I let you _set_ the range of integer variables?
Yeah a lot of functional programming languages have this feature as well. Boxed types are handy.

If, instead of using byte, int, long, etc., we simply indicated the
allowed range of a variable, we might be more aware of these sorts
of issues.  But... what are the downsides of this sort of programming
feature, if any?
This also comes up when you do generic programming, but from a different perspective. When you've done generics for a while, you learn not to make assumptions about when and if you are going to hit min and max values for a type (or tha tthe type even has min and max values, for that matter ;-). Sometimes the best way to avoid having programmers make mistakes is to have them be burned by them repeatedly.

--Chris

--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to