It's true that it hides what happens behind the scenes, but there are several advantages. Rikki Cattermole already mentioned instrumentation; more generally, this makes it easy to change between getter/setter and member variable without modifying all the use sites.

I'd like to add generic code. For an example, look at ranges: their `front` and `empty` must be callable without parens. This makes it possible for some ranges to have a normal member variable `front`, or a static enum member `empty` (which can even be tested for at compile time!), and for others to use methods/UFCS functions instead. Without these, a lot of the generic algorithms in `std.algorithm` would be full of `is(typeof(range.empty)) || is(typeof(range.empty()))`, or similar tests, making them harder to read and get right.

Reply via email to