Re: Could assertThrown be made safe/trusted?

2012-01-18 Thread bearophile
H. S. Teoh: But since this is apparently not yet implemented, just what *is* implemented currently when you specify 'pure'? Common subexpression factorization? Hoisting? Not (yet) memoization, apparently. Common subexpression factorization for strongly pure functions that return integral

Could assertThrown be made safe/trusted?

2012-01-17 Thread simendsjo
At the top of the module: @safe: later unittest { assertThrown(...) } Ooops. AssertThrown not safe. Changing the top to: version(Unittest) {} else { @safe: } makes it work, but then I'll need to use that idom in all safe modules as assert*Thrown is handly methods.

Re: Could assertThrown be made safe/trusted?

2012-01-17 Thread Jonathan M Davis
On Tuesday, January 17, 2012 15:27:04 simendsjo wrote: At the top of the module: @safe: later unittest { assertThrown(...) } Ooops. AssertThrown not safe. Changing the top to: version(Unittest) {} else { @safe: } makes it work, but then I'll need to use that idom in all safe

Re: Could assertThrown be made safe/trusted?

2012-01-17 Thread H. S. Teoh
On Tue, Jan 17, 2012 at 09:07:05AM -0800, Jonathan M Davis wrote: [...] Exception itself isn't @safe yet (its constructor in particular), and I don't think that AssertError is either. A number of stuff like that in druntime and Phobos still needs to be marked @safe or @trusted. [...] Just out

Re: Could assertThrown be made safe/trusted?

2012-01-17 Thread Timon Gehr
On 01/17/2012 08:21 PM, H. S. Teoh wrote: On Tue, Jan 17, 2012 at 09:07:05AM -0800, Jonathan M Davis wrote: [...] Exception itself isn't @safe yet (its constructor in particular), and I don't think that AssertError is either. A number of stuff like that in druntime and Phobos still needs to be

Re: Could assertThrown be made safe/trusted?

2012-01-17 Thread simendsjo
On 17.01.2012 18:07, Jonathan M Davis wrote: On Tuesday, January 17, 2012 15:27:04 simendsjo wrote: At the top of the module: @safe: later unittest { assertThrown(...) } Ooops. AssertThrown not safe. Changing the top to: version(Unittest) {} else { @safe: } makes it work, but then I'll

Re: Could assertThrown be made safe/trusted?

2012-01-17 Thread Jonathan M Davis
On Tuesday, January 17, 2012 20:26:48 simendsjo wrote: So basically @safe is mostly a no-go as of now? Not sure I understand what you mean though.. enforce() can be used in @safe mode. Honestly, I suspect that that's a hole in @safe, since Exception's constructor isn't @safe. But I don't know.

Re: Could assertThrown be made safe/trusted?

2012-01-17 Thread Jonathan M Davis
On Tuesday, January 17, 2012 20:28:52 Timon Gehr wrote: On 01/17/2012 08:21 PM, H. S. Teoh wrote: On Tue, Jan 17, 2012 at 09:07:05AM -0800, Jonathan M Davis wrote: [...] Exception itself isn't @safe yet (its constructor in particular), and I don't think that AssertError is either. A

Re: Could assertThrown be made safe/trusted?

2012-01-17 Thread H. S. Teoh
On Tue, Jan 17, 2012 at 05:04:18PM -0500, Jonathan M Davis wrote: [...] Attribute inferrence is a big step forward in making as much as possible @safe and pure, but there's still plenty to do there. [...] Funny you should mention that, I was just starting to wonder if I should start littering

Re: Could assertThrown be made safe/trusted?

2012-01-17 Thread Timon Gehr
On 01/17/2012 11:31 PM, Jonathan M Davis wrote: On Tuesday, January 17, 2012 14:14:36 H. S. Teoh wrote: On Tue, Jan 17, 2012 at 05:04:18PM -0500, Jonathan M Davis wrote: [...] Attribute inferrence is a big step forward in making as much as possible @safe and pure, but there's still plenty to

Re: Could assertThrown be made safe/trusted?

2012-01-17 Thread Jonathan M Davis
On Tuesday, January 17, 2012 23:40:35 Timon Gehr wrote: I think he is interested in the state of implementation of specific compiler _optimisations_ that make use of function purity in order to prove their correctness. IIRC ldc has CSE for pure functions, but I don't know exactly. I have no