Our template emission strategy is broken

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Nov 12 20:03:28 PST 2015


On 11/12/2015 5:14 PM, deadalnix wrote:
> module a;
>
> struct S(E) {
>      import std.bitfield;
>      mixin(bitfield!(
>          bool, "flag", 1,
>          T, "myT", SizeOf!T,
>          uint, "", 32 - SizeOf!T - 1,
>      ));
> }
>
> module b;
>
> enum MyEnum { Val1, Val2, Val3 }
>
> import a;
> alias UsefulStruct = S!MyEnum; // Boom, MyEnum is undefined
>
> Now you end up having to tie stupid node into your code, like adding all user of
> library X as import in library X. Which sucks, but is forced by the language
> design.
>

The trouble there is that E is turned into MyEnum in the mixin string, and 
MyEnum would be unknown to module a.

You can file an enhancement request on this in bugzilla if you like.


More information about the Digitalmars-d mailing list