property syntax strawman
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sun Aug 2 09:32:16 PDT 2009
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
More information about the Digitalmars-d
mailing list