No bounds checking for dynamic arrays at compile time?
Chris Cain
clcain at uncg.edu
Thu Dec 13 08:31:05 PST 2012
On Thursday, 13 December 2012 at 09:38:18 UTC, bearophile wrote:
> That program seems to have a bug, unless the signature of foo
> becomes (ref int[]).
Indeed. I'm learning how to type on a new keyboard, so most of my
brain power is being spent on figuring out where the keys are. It
took me over 40 minutes to type that whole message. :( I said it
right in my head, fwiw.
> Right, but there are several cases where a little smarter
> compiler is able to see at compile-time that something bad is
> present in the code.
The problem is that it can't solve anything but the most basic of
errors in code. This type of analysis will simultaneously be
computationally expensive and useless in _real_ code. My point is
that, ultimately, run time problems have to be dealt with at run
time.
I wouldn't mind this suggestion except for the fact that it will
take away human resources from much more useful endeavors (not to
mention increasing compilation time). Many suggestions I see the
value in... but I see
almost none here (as I explained, it won't do anything in
non-trivial code that you might actually see using dynamic
arrays).
More information about the Digitalmars-d
mailing list