New library: open multi-methods
Ali Çehreli via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Tue Jul 18 11:21:21 PDT 2017
On 07/18/2017 11:03 AM, jmh530 wrote:
> the mixin(registerMethods); could then be adjusted so that void
> print(virtual!Matrix m); is mixed in automatically because we now know
> how to construct it.
That reminds me: Would the following be possible and better?
// From
void main()
{
updateMethods();
// ...
}
// To
mixin(constructMethods());
void main()
{
// ...
}
constructMethods() could return the following string:
string constructMethods() {
return q{
shared static this() { updateMethods(); }
};
}
If I'm not missing something, this is better because nothing needs to be
added to main and the methods are available before main starts executing
(module initialization order issues still apply.).
Ali
More information about the Digitalmars-d-announce
mailing list