Open Methods: From C++ to D
EntangledQuanta via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Sat Sep 2 13:55:13 PDT 2017
On Saturday, 2 September 2017 at 14:04:07 UTC, Jean-Louis Leroy
wrote:
> On Thursday, 31 August 2017 at 23:37:03 UTC, EntangledQuanta
> wrote:
>> [Windows]
>> I'll try again at some point. I haven't got around to messing
>> with it again.
>
> Did you get a chance?
I'll try real quick again. I'll have to rewrite the code as I
moved on but:
When I just add the mixin and update(to main) I get the error
openmethods.d(1432): Error: function `main` has no members
main.d-mixin-15(15): Error: CTFE failed because of previous
errors in _registerMethods
This is when I have the mixin(registerMethods) in a module that
doesn't use any open methods. It says add once per module in the
help, but I think it means once per module where open methods are
used?
Removing that mixin from main allows it to compile(but I haven't
created any methods yet).
You might look in to adding updateMethods in a static this()
since it will be ran per process and do everything necessary, I
think.
After a few stupid bugs by me, I was able to get it to work!
Pretty much a drop in replacement! I didn't do anything fancy,
very basic, but it did work. It's not a real test but does show
it can, for the most part, replace traditional code.
Strangely enough, I had a protected member that I was using and
it works, I guess because I defined the openmethod in the same
module. I changed it to private and it worked too. So the issues
about encapsulation I thought about before may be irrelevant as
long as the openmethods are used in the same module(which is a
nice feature of D).
So, everything looks good on my end. Once I get around to
creating something new or rewriting some old stuff I'll try to
use them more and see what happens.
More information about the Digitalmars-d-announce
mailing list