Is @nogc attribute implemented in d?
Asked Answered
D

2

5

I made a little program in D that computes Fibonacci's numbers. It was supposed to be the most efficient possible, as I did this to compare D's speed of execution to that of other languages. Then I read about the @nogc attribute at dlang.org (here : http://dlang.org/attribute#nogc) and tried to use it like this :

@nogc
@safe
uint fibonacci(uint index)
{
    if(index < 2)
        return index;

    return fibonacci(index - 2) + fibonacci(index - 1);
}

I tried with DMD 2.065 and GDC 4.8.2 but both tell me : Error: undefined identifier nogc

Am I doing something wrong ? Is @nogc just not implemented for now ?

Dorrie answered 24/7, 2014 at 15:46 Comment(0)
V
7

@nogc is a new attribute and is first implemented in DMD 2.066.

Venter answered 24/7, 2014 at 16:30 Comment(4)
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post.Decretive
So it's a version issue... I guess I'll try to use the newer version. Thanks !Lasagne
@nogc is brand new, just in the newest release.Naumann
@Decretive I believe that my answer provides a sufficient answer to the question "Is @ nogc attribute implemented in d?" assuming this means DMD, the reference implementation. Feel free to disagree. I should probably amend it to point out the version issue more explicitly, though. There we go.Venter
C
1

The first compiler that will support the brand new @nogc feature is the DMD v2.066. The stable release is not out yet, only few betas have been released by now (end of July 2014). Once DMD 2.066 is released, we can rightfully say that D supports it. Until that happens we can only say it is an experimental D feature.

Callida answered 27/7, 2014 at 12:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.