On Wednesday, February 07, 2018 20:17:54 aliak via Digitalmars-d-learn wrote: > On Wednesday, 7 February 2018 at 20:08:10 UTC, Paul Backus wrote: > > You can only call a function with UFCS syntax if the object > > you're calling it with does not have a member with the same > > name as the function. Both iota's `Result` type and > > `FilterResult` have properties named "front", so you can't call > > your front function on them using UFCS syntax. > > ahhh... bummer. > > Do you know if it is a limitation that is yet to be implemented > or one that will not (cannot?) be implemented and if so what the > reason is?
It would be a disaster if free functions could override member functions. For starters, it would be impossible to call the member function if that were allowed, whereas you can always call a free function by not using UFCS. And in general, it's far more desirable to have member function functions override free functions, because then you can do stuff like have have a range override find if it can provide a more efficient implementation than std.algorithm.find. If you want to override what a member function is doing, then you need to wrap the object in a new type. - Jonathan M Davis