Mixin and introspection ordering
    Sebastiaan Koppe 
    mail at skoppe.eu
       
    Wed Oct 16 10:09:51 UTC 2019
    
    
  
On Tuesday, 15 October 2019 at 19:50:33 UTC, Paul Backus wrote:
> On Tuesday, 15 October 2019 at 19:19:58 UTC, Sebastiaan Koppe 
> wrote:
>> You would expect 2 to print `tuple(a)` as well, but it 
>> doesn't. Don't know if it is a bug.
>
> Any time you use a construct that mutates the AST (template 
> mixin, string mixin, static if, static foreach), it's possible 
> to catch it in both "before" and "after" states. For example:
>
> This can cause some "interesting" things to happen when using 
> templates like the ones in std.traits to do reflection, since 
> the result of template instantiation is cached:
Wth the simple examples in this thread it can even be excused. 
However, when the mixin and the introspection are part of 
something larger it is no longer easily apparent.
I myself spend 30min wondering why it didn't work. And I wrote it 
myself.
Do we want to be able to catch things in their 'before' state? Or 
is it a bug?
    
    
More information about the Digitalmars-d-learn
mailing list