2 ms·
There's one advantage of foo.bar calling a function, it works well with referential transparency. Whether it's a property/value or function, only the result mat
by karmakaze 3y ago
There's one advantage of foo.bar calling a function, it works well with referential transparency. Whether it's a property/value or function, only the result matters. I can't say it's a big difference though, I've only been mildly annoyed by having to change all call-sites when changing between them. Other languages allow code bodies for getters/setters (foo.bar = ...) so it still hides the call. For a C-style syntax language having the () seems less surprising.
- Mawr 3y agoWhen it comes to correctness, only the result matters, sure. But not so for performance and code understandability. Obscuring points of arbitrary code execution is awful. The getter/setter pattern is also bad, but a little less so since it's exceedingly rare any real code will get executed there.