Is Anything Holding you back?
Jonas Drewsen via Digitalmars-d
digitalmars-d at puremagic.com
Mon Oct 5 02:08:55 PDT 2015
On Monday, 5 October 2015 at 06:18:45 UTC, Manu wrote:
> You can easily make attributes effectively available at runtime
> by
> building lists of attributed things at compile time.
> I don't understand your problem. Describe the goal?
This is all nice but still not as slick as could be. Say a want
to have a central place to lookup all classes with the Foo()
attribute on it. The classes can be in several files of course so
there are two ways of registering them at compile time to be
available for runtime lookups:
1, Add a static module contructor to each module that registers
the Foo() attribut'ed classes. This constructor is probably
generated at compile time and mixed into the module as a
one-liner.
2, Add a "registration" module that imports all other modules in
order to filter out Foo() attributed classes and register them
for runtime usage.
The first method is bad because you need to mixin code manually
for each module you have.
The second method is bad because you need to keep the
"registration" file in sync with any modules
added/renamed/removed.
A couple of months ago I was working on an extension to the
string import() feature of D: It would simply treat a import(*)
as returning the directory listing of the imports path. From that
the list of .d file could be figured out and imported at compile
time. Then the the runtime information could be extracted at
compile time with no fuzz.
/Jonas
More information about the Digitalmars-d
mailing list