On Thursday, 3 August 2017 at 12:06:02 UTC, Arafel wrote:
Does somebody know how it's even *supposed* to work?
virtual functions can be overridden. All others work as functions across shared namespaces. Overloads across namespaces need to be explicitly added to the overload set, see: http://dlang.org/hijack.html
* Static functions are "virtual", i.e. there is a lookup of parent classes if it's not found. This is not documented, and I didn't even think it would work:
It isn't virtual, more like an import. Same as member variables. idk where this is in the spec though...
This is a bit shocking, since the compiler must know for sure which class I'm from, and I can also make it explicit:
There's no place in the binary for it to pass it that information. With a non-static member, `this` is passed as a hidden function argument. With static, there explicitly are no hidden function arguments (it is compatible with outside function pointers). The template can do it since it creates several copies... and as such is NOT compatible with function pointers.
The function pointer compatibility is fairly important.
* Finally, things get even more confusing with templates: a missing template will be looked up in "parent" classes, but a template that exists but is not instantiable won't:
This has to do with the overload rules, see the hijack article linked above.
