|
|
|
|
|
by AnimalMuppet
1290 days ago
|
|
What are their names? "Member access" is the name of "->". That's a pretty well-understood and easily-understood name. > Worse still, C++ operators are completely unintellible without context. Um, compared to what? The C++ operators require less context to understand than the Haskell lens operators by a large amount, so this seems like a really odd criticism. Your last two paragraphs... yeah. Operator overloading has been used for some, uh, unusual uses, even by the standards committee. |
|
This is my exact point. The C++ operators require much more context.
Suppose you see:
`v << i`
in c++. What is the type of v? What is i? Is it an int? Or an output stream? Or something else entirely! I have no idea. By the C++ standard it could be anything. In fact, it is heavily dependent on what's in scope, and indeed, several different things could overload it depending on what's in scope. Very confusing.
In haskell,
'x ^. i'
tells you everything. 'x' is any type, but 'i' is mandated to relate to 'x' in that 'i' is an optic targeting 'x' and returning some 'subfield' of x. In particular, 'i' is 'Getter a b', where 'a' is the type of 'x'. That is absolute. There is no other interpretation. Haskell type class overlap rules prevent any module imports from confusing the matter.