Life in the Fast Lane (@nogc blog post)
Ali Çehreli via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Tue Jun 20 09:57:20 PDT 2017
On 06/20/2017 09:47 AM, jmh530 wrote:
> On Tuesday, 20 June 2017 at 15:24:06 UTC, Dukc wrote:
>
>>
>> I wasn't skilled enough to make a generic version of this trough. And
>> I do not know what happens if @nogc function ends up calling gc.
>
> This seems like it only would work if you know that there wouldn't be
> any allocations. I don't really know though.
>
> Below is a little more generic:
>
> template gc78f(alias f)
> {
> void gc78f(T...)(T what) @nogc
> {
> import std.stdio;
> alias fType = void function(T) @nogc;
> (cast(fType)&f!T)(what);
> }
> }
>
> void main() @nogc
> {
> import std.stdio;
> string x = "hello world!";
> gc78f!(writeln)(x);
> }
And there is also assumeNoGC() which has been discussed before. (The
scary thing is, although it happened just five months ago I don't
remember taking part in it. :( )
http://forum.dlang.org/post/oat6lu$n94$1@digitalmars.com
Ali
More information about the Digitalmars-d-announce
mailing list