Michiel Helvensteijn wrote:
Andrei Alexandrescu wrote:

I'd like to have an easy enough syntax for defining read-only properties
(often in my code). With the proposed syntax, one writes

bool empty { ... }

and calls it a day, but with the elaborate getters and setters there are
two scopes to get through:

bool empty { auto get() { ... } }

which is quite some aggravation.

The point is not really the grouping of elements within brackets. That just
eliminates some redundancy. It can also look like the following:

void empty.set(bool value) { ... }
bool empty.get() { ... }

and have the same meaning as my earlier example.

Yah, I was thinking the same. This is my #1 fave so far.

Andrei

Reply via email to