On Tue, 25 Nov 2008 16:56:17 -0500, bearophile wrote: > Andrei Alexandrescu: >> The problem is, it's much more annoying than one might imagine. Even >> array.length - 1 is up for scrutiny. Technically, even array.length + 1 >> is a problem because 1 is really a signed int. We could provide >> exceptions for constants, but exceptions are generally not solving the >> core issue. > > That can be solved making array.length signed.
Is that conceptually clean/clear? (If so, I'd like to request an array of length -1.) I like Andrei's proposal because it keeps clarity in such cases: sizes are non-negative quantities. Once you start subtracting ints, it's possibly not a size anymore, in such cases you want the user to decide explicitly. -- Daniel
