June 07, 2018
On Thursday, 7 June 2018 at 12:32:26 UTC, Arafel wrote:
> Thanks for all the answers!
>
> Is it possible to register, say, a base class, and have all the subclasses then registered automatically?
>
> My idea would be to make it as transparent as possible for the plugin implementation, and also not having to depend on it.
>
> A.
>

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.

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.
June 08, 2018
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.

June 08, 2018
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

June 13, 2018
On Friday, 8 June 2018 at 08:21:39 UTC, evilrat wrote:
> 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

Thanks very much for these links!

I'm currently also trying to get a crack at runtime introspection for enabling richer serialization capabilities. It is nice to have compile time code generation, but it really sucks when dealing with object hierarchies and API interfaces.

I'm doing kind of the same thing as witchcraft with explicit mixins (putting a "mixin reflect" into every stuff I want to reflect on.)
But I'd like to have selective reflection/introspection, with a C#-esque flavor of having a "centralised repository" of reflected stuff.


Also I need to inject static this(). A serious drawback.

On that note, you can pass:
--DRT-oncycle=ignore

to your compiled app to instruct the runtime to ignore cycle warnings.
linux ex.: "./app --DRT-oncycle=ignore"

It is ugly as hell to disable this check, but I would accept it gladly if this would be the only impediment of getting runtime reflection.

Sadly it is not, and I don't want to ramble right now :)

1 2
Next ›   Last »