Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
February 08, 2014 pure vs writeln debugging | ||||
---|---|---|---|---|
| ||||
Is there some way to poke enough of a hole in "pure" to get some writeln debugging statements in? |
February 08, 2014 Re: pure vs writeln debugging | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky | 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
|
February 09, 2014 Re: pure vs writeln debugging | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | 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?
|
February 09, 2014 Re: pure vs writeln debugging | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky | 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.
|
February 10, 2014 Re: pure vs writeln debugging | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky | 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.
|
February 11, 2014 Re: pure vs writeln debugging | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | "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; } |
February 12, 2014 Re: pure vs writeln debugging | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Murphy | 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.
|
Copyright © 1999-2021 by the D Language Foundation