@ctfeonly
Nicholas Wilson
iamthewilsonator at hotmail.com
Thu Dec 7 23:41:04 UTC 2017
On Thursday, 7 December 2017 at 21:32:24 UTC, Walter Bright wrote:
> On 12/7/2017 2:07 AM, Nicholas Wilson wrote:
>> Doesn't work for templates.
>
> I don't know how your code is organized, but if the template is
> instantiated in another file, it won't have code generated for
> it either.
As a trivial example:
bar.d:
module bar;
string generatesMixin(T)()
{
return T.stringof ~ " foo;";
}
a.d:
@compute(CompileFor.deviceOnly) module a;
int baz()
{
mixin(generatesMixin!int());
return foo;
}
a's symbol table contains `baz` and `generatesMixin!int`.
generateMixin deals with strings which are not allowed (global
variables are unsupported). This would fail compilation. If
`generatesMixin` were to be marked `@ctfeonly`, this would pass.
More information about the Digitalmars-d
mailing list