"hijackable"/"customizable" keyword for solving the "customized algorithm" issue?

Meta via Digitalmars-d digitalmars-d at puremagic.com
Wed May 14 19:07:34 PDT 2014


On Thursday, 15 May 2014 at 01:49:17 UTC, Idan Arye wrote:
> 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?

That's exactly what the proposed @hijackable annotation on a 
function would do, if I understand it correctly.


More information about the Digitalmars-d mailing list