August 30, 2016
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
August 31, 2016
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:
>>
>> assumeNogc!writefln("foo %s", 42);
>> assumeNogc!writeln("foo", 42);
>
> Marvellous!

+1

> I update my cryptic but short-and-sweet `dln` at
>
> https://github.com/nordlow/phobos-next/blob/master/src/dbg.d#L58
>
> I would love to see this very useful little snippet make its way into Phobos somehow. Any suggestions on how?

I am trying to push for a dump method in Phobos, we could try to combine it:

https://github.com/dlang/phobos/pull/4318

AssumeNogc is potentially dangerous, so I don't know whether it can make it directly, but only if you try you know ;-)
August 31, 2016
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
August 31, 2016
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, 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 bypass compiler checks.
August 31, 2016
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 bypass compiler checks.

assumeNogc works the same way, you're telling the compiler something it doesn't know — that the function should be treated as @nogc. Using assumeNogc on a function that calls the GC is as unsafe as using assumeUnique on a reference that is not unique.
August 31, 2016
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). But when you use assumeNogc, it's always because you want to bypass compiler checks.
>
> assumeNogc works the same way, you're telling the compiler something it doesn't know — that the function should be treated as @nogc. Using assumeNogc on a function that calls the GC is as unsafe as using assumeUnique on a reference that is not unique.

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.
August 31, 2016
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 source code must be available anyway (templates, `auto` return value). For ordinary functions, the compiler only considers them @nogc when they're explicitly marked.

For example, the compiler won't let you do this, even though f's source code is available and it's obviously de-facto @nogc:

----
void f() {}
void main() @nogc { f(); }
----
August 31, 2016
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 not.
>
> Attributes are only inferred in certain cases where the source code must be available anyway (templates, `auto` return value). For ordinary functions, the compiler only considers them @nogc when they're explicitly marked.
>
> For example, the compiler won't let you do this, even though f's source code is available and it's obviously de-facto @nogc:
>
> ----
> void f() {}
> void main() @nogc { f(); }
> ----

That's a good point. By IMHO, all the (non-template) function in Phobos that can be marked @nogc, should be marked @nogc, otherwise it's a bug. If the function is in your own code, you should use @nogc, not assumeNogc.

After a second thought, the real use case of assumeNogc is probably virtual functions. But then again, it is kind of dangerous to use it even in this case.
1 2
Next ›   Last »