On Fri, Jul 27, 2018 at 03:41:29AM +0000, Sameer Pradhan via Digitalmars-d wrote: [...] > Whence came UFCS? [...]
As far as I know, UFCS came about from a particular interpretation of TDPL (Andrei's book). Andrei was talking about the range API, and inserted a little note about how native arrays can be made into ranges by adopting the convention that if: arr.func(...) cannot be resolved as a member function, then the compiler would rewrite it as: func(arr, ...) instead. This would then allow generic code to be written as: while (r.empty) { doSomething(r.front); r.popFront(); } without needing to special case the code for native arrays. Initially, this was only implemented for arrays as a special case, and some people read Andrei's description as applying only to arrays. However, others (including myself) read it as a general principle that ought to apply to all types, even though at the time the compiler had only implemented this for the array case. After quite a lot of debate, eventually somebody (I believe it was Kenji -- man I still miss that guy) implemented a PR for it, and after quite a bit more controversy, the PR was merged. That was when UFCS became a reality. The rest, as they say, was history. T -- People who are more than casually interested in computers should have at least some idea of what the underlying hardware is like. Otherwise the programs they write will be pretty weird. -- D. Knuth