On Friday, 18 April 2014 at 06:50:48 UTC, Brad Anderson wrote:
On Friday, 18 April 2014 at 06:35:33 UTC, Walter Bright wrote:
On 4/17/2014 9:23 PM, Brad Anderson wrote:
Would @nogc apply to code being evaluated at compile-time? I
don't think it should.
Yes, it would be. Compile time functions are not special, in
fact, there is no such thing in D.
But surely something like:
struct S
{
this(int d) { data = d; }
S opBinary(string op)(S rhs) @nogc
{
return S(mixin("data "~op~" rhs.data"));
}
private int data;
}
Would still work, right? There is no GC activity there.
I don't think that's a "compile time function" (hence the "there
is no such thing in D"). Rather, it's a function called in a CTFE
context. It *should* work, since currently, a safe, pure, nothrow
function can call an impure, throwing unsafe one for CTFE.