我用 D 编写了一个计算斐波那契数的小程序。它应该是最高效的,因为我这样做是为了将 D 的执行速度与其他语言的执行速度进行比较。然后我在 dlang.org(这里:http://dlang.org/attribute#nogc)上阅读了@nogc 属性,并尝试像这样使用它:
@nogc
@safe
uint fibonacci(uint index)
{
if(index < 2)
return index;
return fibonacci(index - 2) + fibonacci(index - 1);
}
我尝试使用 DMD 2.065 和 GDC 4.8.2,但都告诉我:
Error: undefined identifier nogc
难道我做错了什么 ? @nogc 暂时没有实现吗?
最佳答案
@nogc
是一个新属性,首先在 DMD 2.066 中实现。
关于attributes - @nogc 属性是否在 d 中实现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24938330/