I want to do this (supported by this), but I'm hitting a tiny issue (watered down for your less-headachy-non-displeasure).
Let's say I'm a library writer, and I have these functions in a D file:
module mod_a;
import std.stdio;
void run(T)(T v) { writeln("Jigglypuff!"); }
void runrun(T)(T v) { run(v); }
And I have client code in another module in which I attempt to overload run and call runrun:
import mod_a;
void run(T:double)(T v) { writeln("Wigglytuff!"); }
void main() { runrun(1.0); }
This code results in 'Jigglypuff!' being printed rather than 'Wigglytuff!', which makes sense, because the definition of runrun can only see the unevolved unspecialized form available to it in its module. I (and client code), however, would like to be seeing a 'Wigglytuff' rather than a 'Jigglypuff'.
In C++ I'd throw a namespace mod_a { ... } around the specialization of run to show that the client code's run should be examined alongside my library code when trying to determine what the definition of runrun calls, welcoming the can of worms that came along with such behavior.
Is there an idiomatic D-way to organize this such that the function run may be intentionally hijacked? Specifically, I'd like to mimic the way C++'s global functions behave with ad-hoc specializations.
run(T)does not overloadmod_a.run(T)at all, you're not in the same module. - Krisrunrun. - userWigglytuffruncall isn't even appearing in its own overload set at therunrundefinition let alone being judged alongside other overload sets, and I want that situation to change. - user