Using getSymbolsByUDA in a static foreach loop
Adam D Ruppe
destructionator at gmail.com
Wed Jan 19 20:53:29 UTC 2022
On Wednesday, 19 January 2022 at 20:46:17 UTC, Jack Stouffer
wrote:
> static foreach(system; getSymbolsByUDA!(Manager,
> Runnable))
> {
> system.run();
> onlineapp.d(16): Error: value of `this` is not known at compile
> time
The getSymbols returns aliases, meaning you hit what I wrote
about a few days ago:
http://dpldocs.info/this-week-in-d/Blog.Posted_2022_01_10.html#tip-of-the-week
The `this` is a runtime value and all the other `static` things
work on compile time info.
So you want to `__traits(child, system, this).run()` and it
should work - the traits child will re-attach a this value.
More information about the Digitalmars-d-learn
mailing list