"hijackable"/"customizable" keyword for solving the "customized algorithm" issue?
Idan Arye via Digitalmars-d
digitalmars-d at puremagic.com
Wed May 14 18:49:15 PDT 2014
On Wednesday, 14 May 2014 at 23:57:24 UTC, Meta wrote:
> It's a good idea, but yet another function annotation is pretty
> much a no-go. How bad an idea is it to *always* defer to a
> member function if the object/struct in question has such a
> function defined? I thought that was the case already... I
> suppose it will cause untold amounts of code breakage. Very
> unfortunate.
UFCS only apply to the method call style, not the the function
call style, so it's not a matter of priority here -
`foo(myObject)` will not call the `foo.myObject()` method even if
there is no `foo` function(in that case it'll just fail).
Having the function call style always defer to a member function
is a really bad idea - and not just because of code breakage.
It'll make it impossible to call a function on an object that has
a method of the same name unless you use an alias or a function
variable to copy the function - but then you have to make sure
the alias\variable name is also not taken!
This will be a disaster for anyone who wants to build or use a D
library that uses templates. Well, how common can that case be?
More information about the Digitalmars-d
mailing list