On Friday, 27 October 2023 at 12:38:10 UTC, Hors wrote:
> It's impossible to tell if reading or writing an object's variable would call a function because of UFCS or @property. it just hurts because you can't know if it's a function call without looking at implementation.
The most basic example is
obj.val = 1; // actually calls obj.setVal(1)
assert(obj.val == 1); // actually calls obj.getVal(), assertion may fail if getVal or setVal is not implemented correctly. Which is unexpected
To fix this hidden function craziness, UFCS needs to require parantheses, and property function needs to be removed entirely.
If you want to know what function is being called, you can always read the documentation.
Every programming language makes its own choices about which details get shown directly in the code, and which details require you to look something up. Ideally, we would like to show the details people care about, and hide the details they don't care about, but different people care about different things, so there is no choice that will make everyone happy.
If you care very strongly about always being able to tell when a function is being called, maybe D isn't the language for you, and you'd prefer a language like C or Rust. Or maybe D has enough other advantages that this is an annoyance you can learn to live with.
Either way, I'd encourage you to keep in mind that your perspective isn't the only one, and that people who care about different things than you have valid reasons for doing so.