Re: Debug prints in @nogc

2016-08-31 Thread Yuxuan Shui via Digitalmars-d-learn
On Wednesday, 31 August 2016 at 19:39:36 UTC, ag0aep6g wrote: On 08/31/2016 09:23 PM, Yuxuan Shui wrote: Correct me if I'm wrong. But I believe this is only true when the source code of function is not available. Otherwise the compiler should always know if a function is actually @nogc or

Re: Debug prints in @nogc

2016-08-31 Thread ag0aep6g via Digitalmars-d-learn
On 08/31/2016 09:23 PM, Yuxuan Shui wrote: Correct me if I'm wrong. But I believe this is only true when the source code of function is not available. Otherwise the compiler should always know if a function is actually @nogc or not. Attributes are only inferred in certain cases where the

Re: Debug prints in @nogc

2016-08-31 Thread Yuxuan Shui via Digitalmars-d-learn
On Wednesday, 31 August 2016 at 18:07:46 UTC, Cauterite wrote: On Wednesday, 31 August 2016 at 16:17:51 UTC, Yuxuan Shui wrote: No. When you use assumeUnique, you know something the compiler does know, and have to use assumeUnique to tell the compiler that (at least when you use it correctly).

Re: Debug prints in @nogc

2016-08-31 Thread Cauterite via Digitalmars-d-learn
On Wednesday, 31 August 2016 at 16:17:51 UTC, Yuxuan Shui wrote: No. When you use assumeUnique, you know something the compiler does know, and have to use assumeUnique to tell the compiler that (at least when you use it correctly). But when you use assumeNogc, it's always because you want to

Re: Debug prints in @nogc

2016-08-31 Thread Yuxuan Shui via Digitalmars-d-learn
On Wednesday, 31 August 2016 at 15:52:18 UTC, Cauterite wrote: On Wednesday, 31 August 2016 at 15:10:11 UTC, Seb wrote: AssumeNogc is potentially dangerous, so I don't know whether it can make it directly, but only if you try you know ;-) So is assumeUnique No. When you use assumeUnique,

Re: Debug prints in @nogc

2016-08-31 Thread Cauterite via Digitalmars-d-learn
On Wednesday, 31 August 2016 at 15:10:11 UTC, Seb wrote: AssumeNogc is potentially dangerous, so I don't know whether it can make it directly, but only if you try you know ;-) So is assumeUnique

Re: Debug prints in @nogc

2016-08-31 Thread Seb via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 19:03:06 UTC, Nordlöw wrote: On Tuesday, 30 August 2016 at 17:11:48 UTC, Johannes Pfau wrote: Nice! Here's a slightly modified version: https://dpaste.dzfl.pl/8c5ec90c5b39 This version does not need an additional delegate. It can be used like this:

Re: Debug prints in @nogc

2016-08-30 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 19:03:06 UTC, Nordlöw wrote: https://github.com/nordlow/phobos-next/blob/master/src/dbg.d#L58 Renamed to https://github.com/nordlow/phobos-next/blob/master/src/dbgio.d#L58

Re: Debug prints in @nogc

2016-08-30 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 17:11:48 UTC, Johannes Pfau wrote: Nice! Here's a slightly modified version: https://dpaste.dzfl.pl/8c5ec90c5b39 This version does not need an additional delegate. It can be used like this: assumeNogc!writefln("foo %s", 42); assumeNogc!writeln("foo", 42);

Re: Debug prints in @nogc

2016-08-30 Thread Johannes Pfau via Digitalmars-d-learn
Am Tue, 30 Aug 2016 16:37:53 + schrieb Cauterite : > On Tuesday, 30 August 2016 at 14:38:47 UTC, Nordlöw wrote: > > Just being able to print a string is not good enough. I want > > the variadic part writeln so I can debug-print values in my > > buggy code. Do you have a

Re: Debug prints in @nogc

2016-08-30 Thread Cauterite via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 14:38:47 UTC, Nordlöw wrote: Just being able to print a string is not good enough. I want the variadic part writeln so I can debug-print values in my buggy code. Do you have a similar solution? Take a look at the example here:

Re: Debug prints in @nogc

2016-08-30 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 11:52:21 UTC, Johannes Pfau wrote: import std.stdio; debug { enum writelnPtr = !string; enum void function(string) @nogc writelnNoGC = cast(void function(string) @nogc)writelnPtr; } void main() @nogc { debug writelnNoGC("foo"); } Just being

Re: Debug prints in @nogc

2016-08-30 Thread Johannes Pfau via Digitalmars-d-learn
Am Tue, 30 Aug 2016 10:26:28 + schrieb Nordlöw : > I'm struggling with debug printing in my @nogc-containers. > > The alternatives: > > assert(false, "Fixed message with no parameters"); > > is not enough for my needs > > debug writeln("Fixed"); > >

Re: Debug prints in @nogc

2016-08-30 Thread rikki cattermole via Digitalmars-d-learn
On 30/08/2016 11:10 PM, Nordlöw wrote: On Tuesday, 30 August 2016 at 10:36:13 UTC, rikki cattermole wrote: On 30/08/2016 10:26 PM, Nordlöw wrote: I'm struggling with debug printing in my @nogc-containers. The alternatives: assert(false, "Fixed message with no parameters"); is not enough

Re: Debug prints in @nogc

2016-08-30 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 10:36:13 UTC, rikki cattermole wrote: On 30/08/2016 10:26 PM, Nordlöw wrote: I'm struggling with debug printing in my @nogc-containers. The alternatives: assert(false, "Fixed message with no parameters"); is not enough for my needs debug

Re: Debug prints in @nogc

2016-08-30 Thread rikki cattermole via Digitalmars-d-learn
On 30/08/2016 10:26 PM, Nordlöw wrote: I'm struggling with debug printing in my @nogc-containers. The alternatives: assert(false, "Fixed message with no parameters"); is not enough for my needs debug writeln("Fixed"); doesn't bypass @nogc checking. Why? And temporary commenting out

Re: Debug prints in @nogc

2016-08-30 Thread Seb via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 10:26:28 UTC, Nordlöw wrote: I'm struggling with debug printing in my @nogc-containers. The alternatives: assert(false, "Fixed message with no parameters"); is not enough for my needs debug writeln("Fixed"); doesn't bypass @nogc checking. Why? And

Debug prints in @nogc

2016-08-30 Thread Nordlöw via Digitalmars-d-learn
I'm struggling with debug printing in my @nogc-containers. The alternatives: assert(false, "Fixed message with no parameters"); is not enough for my needs debug writeln("Fixed"); doesn't bypass @nogc checking. Why? And temporary commenting out @nogc is cumbersome. I'm aware of