Contracts or Exceptions?

Kagamin spam at here.lot
Thu Mar 31 10:44:52 PDT 2011


Kai Meyer Wrote:

> On 03/30/2011 08:25 AM, Kagamin wrote:
> > Kai Meyer Wrote:
> >
> >> do all the checking before hand. Arrays are a good example. When not in
> >> -release mode, array boundaries are checked upon every access to the
> >> array, and an exception is thrown if access goes out of bounds. In
> >> -release mode, if you go out of bounds you get a segfault.
> >
> > No, you get a remote root vulnerability.
> 
> Sure, but the point is that arrays can be used in a way that performs as 
> fast as possible, therefore it becomes the programmer's job to ensure 
> that all access to the array is within bounds, which is faster than 
> making the array check itself every time.

It is faster, but I'm not sure it's so much faster to be worth doing. Really, you shouldn't ship unsafe version by default. It should be the user's right, decision and responsibility to do it.


More information about the Digitalmars-d-learn mailing list