On Fri, Apr 27, 2012 at 08:29:40PM +0200, Joseph Rushton Wakeling wrote: > 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?
The "strong/weak" distinction is deduced by the compiler internally. > >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. In -release mode, array bounds checking is turned off for speed reasons. The idea being that before you compile with -release you've already extensively tested your program and are sure that simple bugs like array overruns have been weeded out. T -- IBM = I Blame Microsoft