Open Methods: From C++ to D
Q. Schroll via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Wed Aug 30 09:37:20 PDT 2017
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.
More information about the Digitalmars-d-announce
mailing list