On Friday, 8 June 2018 at 08:06:27 UTC, Arafel wrote:
On Thursday, 7 June 2018 at 13:07:21 UTC, evilrat wrote:
I don't think so. It clearly states that children must mixin
too, which can mean it just grabs symbols in scope only, and
base class has no way of knowing about its subclasses. It also
has "agressive mode" that will make metadata for all public
symbols(?) it can walk, this may or may not be helpful
depending on your requirements.
Yes, that's what I understood from looking at it, but perhaps I
was just missing something. I wonder though how the "agressive
mode" would work with separate compilation / dlopen'ed
libraries. Perhaps I should give it a try and see what happens.
Besides there is no way(not that I am aware of) to make self
registering stuff happen, you still need to call it somewhere.
The most transparent option is probably just doing a mixin in
each module that performs registration of all module symbols
in module ctor.
The point is that there is absolute requirement to make
explicit call for that, be it a module ctor mixin, class mixin
or even user provided registration both at compile time or run
time.
But since it is MIT licensed you can probably use the code as
the starting point and adjust to your own needs.
BTW plug-ins is something that is right now possible on
Linux(not sure about support on other *NIX systems), but in a
very primitive form on Windows.
This is related to DLL support issues(such as type information
not being passed across process/DLL boundaries), these issues
also may include runtime issues as well such as inability to
delegate the GC, which will mean there will be 2(or more)
concurrent running GC's. But again I am not aware of the
current situation.
Well, I'm already tightly coupled to linux, so this is not a
big concern for me :-)
I'll keep trying, as I said, my intention was to let plugin
writers do it as easily as possible, but well, adding some kind
of "register" function might be necessary in the end...
A.
Yep. Like I said probably the easiest to use way is to place
single call in each module. And there probably no other solution,
because modules creates sort of isolated graph via imports. And I
am not aware of any way to get list of modules passed in with
compiler invocation to perform some sort of centralized one-liner
registration.
But anyway look at this, might give some tips on how it can be
done
mixin
https://github.com/Circular-Studios/Dash/blob/b7d589ad4ca8993445c136b6a4ae170932bb7962/source/dash/components/component.d#L208
(note that it uses static this() - module constructor. I think
this behavior was changed around 2015-2016 and now it will cause
cyclic dependency errors when modules with ctors import each
other)
usage
https://github.com/Circular-Studios/Dash/blob/b7d589ad4ca8993445c136b6a4ae170932bb7962/source/dash/components/lights.d#L12