www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - pure vs writeln debugging

reply Nick Sabalausky <SeeWebsiteToContactMe semitwist.com> writes:
Is there some way to poke enough of a hole in "pure" to get some writeln 
debugging statements in?
Feb 08 2014
parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
On Saturday, 8 February 2014 at 22:27:39 UTC, Nick Sabalausky 
wrote:
 Is there some way to poke enough of a hole in "pure" to get 
 some writeln debugging statements in?
literally write debug writeln(..) abnd it should work in the pure function
Feb 08 2014
parent reply Nick Sabalausky <SeeWebsiteToContactMe semitwist.com> writes:
On 2/8/2014 5:30 PM, Adam D. Ruppe wrote:
 On Saturday, 8 February 2014 at 22:27:39 UTC, Nick Sabalausky wrote:
 Is there some way to poke enough of a hole in "pure" to get some
 writeln debugging statements in?
literally write debug writeln(..) abnd it should work in the pure function
Nice! So I take it purity enforcement is disabled with the -debug flag? Or is it some sort of hack with writeln?
Feb 08 2014
next sibling parent "Adam D. Ruppe" <destructionator gmail.com> writes:
On Sunday, 9 February 2014 at 00:18:28 UTC, Nick Sabalausky wrote:
 So I take it purity enforcement is disabled with the -debug 
 flag? Or is it some sort of hack with writeln?
The debug statement specifically (which is only compiled in when you use the -debug flag). debug foo(); will work in a pure function, even if foo is not pure.
Feb 08 2014
prev sibling parent reply "Jesse Phillips" <Jesse.K.Phillips+D gmail.com> writes:
On Sunday, 9 February 2014 at 00:18:28 UTC, Nick Sabalausky wrote:
 On 2/8/2014 5:30 PM, Adam D. Ruppe wrote:
 On Saturday, 8 February 2014 at 22:27:39 UTC, Nick Sabalausky 
 wrote:
 Is there some way to poke enough of a hole in "pure" to get 
 some
 writeln debugging statements in?
literally write debug writeln(..) abnd it should work in the pure function
Nice! So I take it purity enforcement is disabled with the -debug flag? Or is it some sort of hack with writeln?
It is a compiler benefit. Wish it would work with safe and nothrow too, granted writeln should eventually be safe/trusted anyway.
Feb 09 2014
parent reply "Daniel Murphy" <yebbliesnospam gmail.com> writes:
"Jesse Phillips"  wrote in message 
news:vaatltklsmbmdnabojip forum.dlang.org...

 Wish it would work with  safe and nothrow too, granted writeln should 
 eventually be  safe/trusted anyway.
I just travelled back in time and granted your wish! int x; int* p; void main() pure nothrow safe { debug x = 3; debug throw new Exception(null); debug *(p+7) = 2; }
Feb 10 2014
parent "Jesse Phillips" <Jesse.K.Phillips+D gmail.com> writes:
On Tuesday, 11 February 2014 at 07:52:57 UTC, Daniel Murphy wrote:
 "Jesse Phillips"  wrote in message 
 news:vaatltklsmbmdnabojip forum.dlang.org...

 Wish it would work with  safe and nothrow too, granted writeln 
 should eventually be  safe/trusted anyway.
I just travelled back in time and granted your wish! int x; int* p; void main() pure nothrow safe { debug x = 3; debug throw new Exception(null); debug *(p+7) = 2; }
I guess I wasn't clear, when I compile with -debug I should be able to use writeln in an safe/nothrow function just as it is with pure.
Feb 11 2014