On Friday, 16 May 2014 at 16:50:37 UTC, Yota wrote:
On Wednesday, 14 May 2014 at 18:05:44 UTC, monarch_dodra wrote:
...
I just had a crazy idea. "hijackable" keyword (yeah... another keyword):

Given a function:
"Ret foo(T input, Args... args) @hijackable"

Then, when the compiler sees:
"foo(input, args);"

It will always forward directly to T.foo if T.foo exists, bypassing std.foo entirely.
...

What about stuff like this:
  import some.pkg;
  some.pkg.foo(x);

Does this still call x.foo()?

In theory, yes, because "some.pkg" would *be* X.foo, or at the very least, a very thin wrapper. You'd get the very same result with "static if" based implementation, such as "moveFront", where "std.range.moveFront(r)" still just calls "r.moveFront()". Ditto for "take", which just calls opSlice.

What if 'foo' is an alias for 'bar', or vice versa?

An alias shouldn't change anything I think.

Reply via email to