user defined no bounds check

Jonathan M Davis jmdavisProg at gmx.com
Mon Aug 20 02:58:39 PDT 2012


On Monday, August 20, 2012 11:45:23 monarch_dodra wrote:
> On Monday, 20 August 2012 at 09:10:47 UTC, Jonathan M Davis wrote:
> > On Monday, August 20, 2012 10:43:43 monarch_dodra wrote:
> >> There is a way to prevent bounds checking of array accesses
> >> when
> >> compiling. I was wondering if there was a way to have a user
> >> defined range apply the same scheme? I'd suppose using a
> >> "version"? I'm not very fluent with this yet...
> > 
> > I believe that your only options are assert, debug blocks, and
> > version blocks.
> > There's no way for code to no whether -noboundscheck is used
> > just like there's
> > no way for code to know whether -release is used.
> > 
> > - Jonathan M Davis
> 
> For my personal education, what is the rationale behind not being
> able to write:
> "version(noboundscheck)"
> or
> "version(release)"
> ?
> 
> Is it purposefully done to force the implementer to provide his
> own version "word" and "switch"?

I'm not sure that it was ever even considered that the programmer might want 
to do something special with them. assert is affected by -release, and -
noboundscheck was added later for extra control. They had nothing to do with 
the programmer doing anything in their code. I have no idea how Walter would 
feel about adding noboundscheck and/or release versions which correspond to 
the flags.

But since it's generally bad practice to make code differ between non-release 
mode and release mode, and assert already gives you the ability to have checks 
that which are around in non-release but not in release, I don't know that it 
really buys you much to add such version identifiers.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list