Open Methods: From C++ to D

Jean-Louis Leroy via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Wed Aug 30 10:24:55 PDT 2017


On Wednesday, 30 August 2017 at 16:37:20 UTC, Q. Schroll wrote:
> In the article it says:
>> Finally, main calls updateMethods. This should be done before 
>> calling any method (typically first thing in main) and each 
>> time a library containing methods is dynamically loaded or 
>> unloaded.
>
> If the something has to be done at the beginning, we have a 
> tool for that: static this (on module level). The 
> mixin(registerMethods); at the top should therefore mix in.
>
>   static this() { updateMethods(); }
>
> It's never wrong: Calling it in main, too, will at most be 
> redundant. You can still call it manually, but for the part of 
> main, you cannot inadvertently forget it. You can still have 
> static this in that module as you may have multiple static this.

We had a discussion about automating the call to updateMethods 
but I don't think that anybody thought of putting it in 
registerMethods. It might work. I'll look into it. Thanks for the 
suggestion...


More information about the Digitalmars-d-announce mailing list