New library: open multi-methods
jmh530 via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Wed Jul 19 09:06:39 PDT 2017
On Wednesday, 19 July 2017 at 15:56:06 UTC, Jean-Louis Leroy
wrote:
>
> Among other things, the mixin introduces two functions in the
> module's scope: the function the user actually calls (the
> "dispatcher"). E.g. it creates a times(double, Matrix) when it
> sees a times(double, virtual!Matrix). It also declares a
> "discriminator" function which is used to locate which method
> the specializations (the @method funcs) relates to (it has to
> deal with overloads - there are two "times" methods). This has
> to be done for every module that contains method declarations
> (virtual!) or implementations (@method). That's why it has to
> be a string mixin (at least until we have static foreach) and
> be called in the matrix etc modules, not in module openmethods.
I see what you mean. It only works per thread, not per module.
What you really need is some kind of module constructor.
More information about the Digitalmars-d-announce
mailing list