property syntax strawman

Michiel Helvensteijn m.helvensteijn.remove at gmail.com
Sun Aug 2 09:00:06 PDT 2009


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.

-- 
Michiel Helvensteijn




More information about the Digitalmars-d mailing list