Jump to page: 1 24  
Page
Thread overview
debug = x overrides command line
Oct 21, 2014
Gary Willoughby
Oct 21, 2014
Gary Willoughby
Oct 21, 2014
Gary Willoughby
Oct 21, 2014
Walter Bright
Oct 21, 2014
Gary Willoughby
Oct 21, 2014
anonymous
Oct 21, 2014
Gary Willoughby
Oct 21, 2014
Gary Willoughby
Oct 22, 2014
Marco Leise
Oct 22, 2014
Walter Bright
Oct 22, 2014
Walter Bright
Oct 22, 2014
Gary Willoughby
Oct 22, 2014
ketmar
Oct 22, 2014
Jonathan M Davis
Oct 22, 2014
Walter Bright
Oct 22, 2014
Jonathan M Davis
Oct 22, 2014
Walter Bright
Oct 23, 2014
Jonathan M Davis
Oct 23, 2014
Daniel Murphy
Oct 23, 2014
Walter Bright
Oct 23, 2014
Brad Roberts
Oct 24, 2014
Marc Schütz
Oct 24, 2014
Gary Willoughby
Oct 24, 2014
Jacob Carlborg
Oct 26, 2014
Dicebot
October 21, 2014
Currently, if you write something like this:

debug = x;

It's like you passed -debug=x on the command line. However, this seems quite scary. It means that you are debugging ALL THE TIME, with any debug(x) statements.

Does this make sense? Note that debug disables pure checking, which can be dangerous. I'm kind of uneasy that if I don't pass any debug arguments to the compiler, it can still violate purity in the name of debugging with such statements.

I would have expected debug = x to only be enabled when -debug is passed to the compiler. Does this make sense to anyone?

Note, there is no way to simply enable the same thing as -debug does in code.

-Steve
October 21, 2014
On Tuesday, 21 October 2014 at 15:45:55 UTC, Steven Schveighoffer wrote:
> Currently, if you write something like this:
>
> debug = x;

In code? Like this:

void main()
{
    debug = x;

    // now in debug mode even though not specified on the CLI?
}

If that's true, that's pretty scary. What if it's hidden in a module somewhere?
October 21, 2014
On 10/21/14 12:02 PM, Gary Willoughby wrote:
> On Tuesday, 21 October 2014 at 15:45:55 UTC, Steven Schveighoffer wrote:
>> Currently, if you write something like this:
>>
>> debug = x;
>
> In code? Like this:
>
> void main()
> {
>      debug = x;
>
>      // now in debug mode even though not specified on the CLI?
> }
>

Yes, but only for debug(x) statements. debug statements without a symbol aren't enabled. But for those statements, purity is jettisoned. e.g.:

import std.stdio;
int a;

void foonotpure() { a = 5; writeln("yep, not pure");}

debug = x; // note this is only allowed at module scope.
void main() pure
{
   debug(x) foonotpure();
}

dmd -run foonotpure.d
yep, not pure

> If that's true, that's pretty scary. What if it's hidden in a module
> somewhere?

Yep, you can just turn off purity when it gets in the way.

-Steve
October 21, 2014
On Tuesday, 21 October 2014 at 17:25:37 UTC, Steven Schveighoffer wrote:
> On 10/21/14 12:02 PM, Gary Willoughby wrote:
>> On Tuesday, 21 October 2014 at 15:45:55 UTC, Steven Schveighoffer wrote:
>>> Currently, if you write something like this:
>>>
>>> debug = x;
>>
>> In code? Like this:
>>
>> void main()
>> {
>>     debug = x;
>>
>>     // now in debug mode even though not specified on the CLI?
>> }
>>
>
> Yes, but only for debug(x) statements. debug statements without a symbol aren't enabled. But for those statements, purity is jettisoned. e.g.:
>
> import std.stdio;
> int a;
>
> void foonotpure() { a = 5; writeln("yep, not pure");}
>
> debug = x; // note this is only allowed at module scope.
> void main() pure
> {
>    debug(x) foonotpure();
> }
>
> dmd -run foonotpure.d
> yep, not pure
>
>> If that's true, that's pretty scary. What if it's hidden in a module
>> somewhere?
>
> Yep, you can just turn off purity when it gets in the way.
>
> -Steve

Wow!
October 21, 2014
On Tuesday, 21 October 2014 at 17:25:37 UTC, Steven Schveighoffer
wrote:
> Yep, you can just turn off purity when it gets in the way.
>
> -Steve

Please raise a ticket for this.
October 21, 2014
On 10/21/2014 12:15 PM, Gary Willoughby wrote:
> On Tuesday, 21 October 2014 at 17:25:37 UTC, Steven Schveighoffer
> wrote:
>> Yep, you can just turn off purity when it gets in the way.
>>
>> -Steve
>
> Please raise a ticket for this.

That was done deliberately - it's a feature. It enables things like debugging printf's to be inserted into pure functions.
October 21, 2014
On Tuesday, 21 October 2014 at 19:24:03 UTC, Walter Bright wrote:
> On 10/21/2014 12:15 PM, Gary Willoughby wrote:
>> On Tuesday, 21 October 2014 at 17:25:37 UTC, Steven Schveighoffer
>> wrote:
>>> Yep, you can just turn off purity when it gets in the way.
>>>
>>> -Steve
>>
>> Please raise a ticket for this.
>
> That was done deliberately - it's a feature. It enables things like debugging printf's to be inserted into pure functions.

Ah, where's the documentation for this?
October 21, 2014
On Tuesday, 21 October 2014 at 19:51:34 UTC, Gary Willoughby
wrote:
> Ah, where's the documentation for this?

http://dlang.org/function.html#pure-functions

> As a concession to practicality, a pure function can:
[...]
> perform impure operations in statements that are in a ConditionalStatement controlled by a DebugCondition.
October 21, 2014
On Tuesday, 21 October 2014 at 19:58:40 UTC, anonymous wrote:
> On Tuesday, 21 October 2014 at 19:51:34 UTC, Gary Willoughby
> wrote:
>> Ah, where's the documentation for this?
>
> http://dlang.org/function.html#pure-functions
>
>> As a concession to practicality, a pure function can:
> [...]
>> perform impure operations in statements that are in a ConditionalStatement controlled by a DebugCondition.

Right, that's all well and good but where does it say that you can assign a value to the debug keyword (in code) and it executes as if you had specified debug on the command line?
October 21, 2014
On Tuesday, 21 October 2014 at 20:57:03 UTC, Gary Willoughby wrote:
> On Tuesday, 21 October 2014 at 19:58:40 UTC, anonymous wrote:
>> On Tuesday, 21 October 2014 at 19:51:34 UTC, Gary Willoughby
>> wrote:
>>> Ah, where's the documentation for this?
>>
>> http://dlang.org/function.html#pure-functions
>>
>>> As a concession to practicality, a pure function can:
>> [...]
>>> perform impure operations in statements that are in a ConditionalStatement controlled by a DebugCondition.
>
> Right, that's all well and good but where does it say that you can assign a value to the debug keyword (in code) and it executes as if you had specified debug on the command line?

Aha http://dlang.org/version.html#DebugCondition
« First   ‹ Prev
1 2 3 4