Passing array as const slows down code?

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Fri Apr 27 11:29:40 PDT 2012


On 27/04/12 20:25, H. S. Teoh wrote:
> On Fri, Apr 27, 2012 at 07:25:30PM +0200, Joseph Rushton Wakeling wrote:
>> I was more concerned that the compiler wasn't identifying what to me
>> was a violation of purity.  I'm fairly sure I can also find a way to
>> make some of those "nothrow" functions throw an error ...
>
> It's not a violation of purity, it's just "weak purity". If you try to
> access a global variable, for example, it will trigger an error.

Thanks for the extended description of weak purity -- it's been very helpful in 
understanding the concept better.

Is there a particular way in which I can explicitly mark a function as strongly 
pure?

> And nothrow functions *are* allowed to throw Error objects. That's also
> a deliberate decision. :-)

... yes, as I just found out when I decided to test it 2 minutes ago :-)  OTOH I 
found that with or without the nothrow option, when the -release flag was used 
in compiling the code, the error was not thrown and the program did not exit -- 
it just sat there seemingly running but doing nothing.  This was unexpected ...

The deliberate error was in this case a range exception when accessing an array.


More information about the Digitalmars-d-learn mailing list