我用 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 现在还没有实施吗?