Comment

Comment by stabbles

Also Bjarne Strostroup said that this (pun intended) was a mistake, since often there is no "most important" object.

If you want to do generic programming, it's much better to write f(a, b) instead of a.f(b).

Suppose I'm writing a generic algorithm that needs some function distance(A a, B b) for generic A and B. Distance is probably a commutative function, why would a.distance(b) be better than b.distance(a)? It's arbitrary.

Secondly, if functions are first-class citizens, and I don't "own" the types A and B, it's much easier to implement distance(A a, B b) myself than it is to extend the types A and B with a member function `distance`.

parent stabbles 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton