Thread overview
Re: option -ignore_pure for temporary debugging (or how to wrap an unpure function inside a pure one)?
Feb 08, 2018
Timothee Cour
Feb 09, 2018
Timothee Cour
February 07, 2018
same question with how to wrap a gc function inside a nogc shell, if not, allowing a flag -ignore_nogc that'd enable this (again, for debugging purposes)

On Wed, Feb 7, 2018 at 7:29 PM, Timothee Cour <thelastmammoth@gmail.com> wrote:
> while hacking into druntime and adding temporary debug information (eg with custom logging etc) I had a hard time making things compile because lots of functions are pure nothrow safe, resulting in compile errors when my custom debugging functions are not pure nothrow safe.
>
>
> How about adding flags ` -ignore_pure` (and perhaps -ignore_safe -ignore_nothrow) to allow code to compile ignoring safe, pure, nothrow mismatches?
>
> This would be meant for temporary debugging obviously, production code would not enable these flags.
>
> my workaround for nothrow and safe attributes is to call via wrapNothrow!fun:
>
> @trusted
> nothrow auto wrapNothrow(alias fun, T...)(T a){
>   import std.exception;
>   try{
>     return fun(a);
>   }
>   catch(Exception t){
>     assert(0, t.msg);
>   }
> }
>
> What would be a workaround to wrap a non-pure function?
February 08, 2018
On 2/7/18 10:32 PM, Timothee Cour wrote:
> same question with how to wrap a gc function inside a nogc shell, if
> not, allowing a flag -ignore_nogc that'd enable this (again, for
> debugging purposes)

If you wrap the call in a debug block, it will work.

int foo() pure
{
   debug writeln("yep, this works");
}

-Steve
February 08, 2018
On 2/8/18 8:32 AM, Steven Schveighoffer wrote:
> On 2/7/18 10:32 PM, Timothee Cour wrote:
>> same question with how to wrap a gc function inside a nogc shell, if
>> not, allowing a flag -ignore_nogc that'd enable this (again, for
>> debugging purposes)
> 
> If you wrap the call in a debug block, it will work.
> 
> int foo() pure
> {
>     debug writeln("yep, this works");
> }

Gah, I see this was answered 2 other times, but for some reason, your replies turn out as new threads.

Sorry for the extra noise.

-Steve
February 08, 2018
just filed https://issues.dlang.org/show_bug.cgi?id=18407
Issue 18407 - debug should escape nothrow, @nogc, @safe (not just pure)

On Thu, Feb 8, 2018 at 5:38 AM, Steven Schveighoffer via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> On 2/8/18 8:32 AM, Steven Schveighoffer wrote:
>>
>> On 2/7/18 10:32 PM, Timothee Cour wrote:
>>>
>>> same question with how to wrap a gc function inside a nogc shell, if not, allowing a flag -ignore_nogc that'd enable this (again, for debugging purposes)
>>
>>
>> If you wrap the call in a debug block, it will work.
>>
>> int foo() pure
>> {
>>     debug writeln("yep, this works");
>> }
>
>
> Gah, I see this was answered 2 other times, but for some reason, your replies turn out as new threads.
>
> Sorry for the extra noise.
>
> -Steve