Error: Declaration is not yet implemented in CTFE
Daniel Kozak via Digitalmars-d
digitalmars-d at puremagic.com
Fri Nov 28 15:41:03 PST 2014
Dne Fri, 28 Nov 2014 22:55:27 +0100 bitwise via Digitalmars-d
<digitalmars-d at puremagic.com> napsal(a):
> On Friday, 28 November 2014 at 19:24:33 UTC, Daniel Kozak via
> Digitalmars-d wrote:
>> Dne Fri, 28 Nov 2014 20:01:41 +0100 bitwise via Digitalmars-d
>> <digitalmars-d at puremagic.com> napsal(a):
>>
>>> The docs for template mixins do show mixins inside functions, so is
>>> this a bug, or is there something else I'm doing wrong?
>>>
>>> //**************************
>>> module main;
>>> import std.traits;
>>>
>>> class ModInfo {
>>>
>>> }
>>>
>>> mixin template moduleInfo(alias MODULE) {
>>> static const(ModInfo) __module_info = new ModInfo;
>>> }
>>>
>>> const(ModInfo) getModuleInfo(alias mod)() {
>>> static if(__traits(hasMember, mod, "__module_info")) {
>>> return __traits(getMember, mod, "__module_info");
>>> } else {
>>> mixin moduleInfo!mod; // ERROR [1]
>>> return __module_info;
>>> }
>>> }
>>>
>>> void main() {
>>> static const(ModInfo) info = getModuleInfo!(main);
>>> }
>>> //**************************
>>>
>>> [1] main.d(17,3): Error: Declaration mixin moduleInfo!(main);
>>> is not yet implemented in CTFE
>>> main.d(23,31): called from here: getModuleInfo()
>>
>>
>> module main;
>>
>> immutable class ModInfo {
>>
>> }
>>
>> static moduleInfo(alias MODULE)() {
>> return new ModInfo();
>> }
>>
>> static getModuleInfo(alias mod)() {
>> static if(__traits(hasMember, mod, "__module_info")) {
>> return __traits(getMember, mod, "__module_info");
>> } else {
>> return moduleInfo!mod;
>> }
>> }
>>
>> void main() {
>> immutable info = getModuleInfo!(main);
>> }
>
> Thanks, but this still doesn't fix my problem. The idea is that
> getModuleInfo should return the same static copy of ModInfo at each call
> to avoid duplication. ModInfo is a recursive reflection of an entire
> module, so it could be huge.
>
Yes this will
More information about the Digitalmars-d
mailing list