4 ms·
The code isn't readable (you can't even reliably tell at a glance what the operator does) and it takes negligibly longer to write "add()" rather than "+" in you
by throwaway894345 3y ago
The code isn't readable (you can't even reliably tell at a glance what the operator does) and it takes negligibly longer to write "add()" rather than "+" in your program (yes, 'add()' is more keystrokes and thus takes longer to type, but most of your program isn't addition instructions).
I think what people should advocate is full DSL capabilities with some unambiguous gate syntax so people know precisely that `foo * bar` is not using the host language syntax. Overloading operators is ambiguous and vastly incomplete (everyone is holding up matrix math as the shining example for the utility of operator overloading and you can't even express dot product notation in C++!)--it's a hack at best.
- josefx 3y ago> The code isn't readable (you can't even reliably tell at a glance what the operator does) and it takes negligibly longer to write "add()" rather than "+" in your program (yes, 'add()' is more keystrokes and thus takes longer to type, but most of your program isn't addition instructions). Except now you replaced + with a name that tells you just as much/little as + does. So you made your program verbose for the sake of verbosity.
- throwaway894345 3y agoNo, you’ve made your program “verbose” (by a handful of characters) for the sake of clarity—there is no longer ambiguity about what code runs (of course, this assumes you aren’t similarly overloading named functions, which should also be disallowed).
- josefx 3y agoGiven that your example uses neither namespacing nor explicit typing you seem to preach do as I say, not as I do.
- throwaway894345 3y agoI don't know what example you're talking about. I haven't given an example in this thread. I think you may have me confused with another commenter.
- josefx 3y agoso that throwaway suggesting that add is barely longer than + wasn't you?
- throwaway894345 3y agoThat was me, but I didn’t provide example code that would require namespaces. I don’t understand his your earlier comment makes sense in the context of this thread.
- deleted 3y ago[deleted]