Tip of the week: use mixin to hack around order-of-eval problems

Posted 2022-01-24

Core D Development Statistics

In the community

Community announcements

See more at the announce forum.

Tip of the Week

This brought to you by snarwin: if you ever have an order-of-evaluation problem, mixin might help:


alias Thing = Test;


mixin("alias Thing = Test;");

Just wrapping the whole thing in a mixin string. Since the compiler processes mixins in the order they appear in the source rather than in the pseudo-parallel way it normally tries to process declarations, this can force a certain order and possibly force that Thing to be processed after Test is created.