property syntax strawman
Denis Koroskin
2korden at gmail.com
Sun Aug 2 03:30:46 PDT 2009
On Sun, 02 Aug 2009 13:00:38 +0400, Michiel Helvensteijn
<m.helvensteijn.remove at gmail.com> wrote:
> Walter Bright wrote:
>
>> bool empty { ... }
>> void empty=(bool b) { ... }
>>
>> The only problem is when a declaration but not definition is desired:
>>
>> bool empty;
>>
>> but oops! That defines a field. So we came up with essentially a hack:
>>
>> bool empty{}
>>
>> i.e. the {} means the getter is declared, but defined elsewhere.
>>
>> What do you think?
>
> It is quite hack-ish. There are ways to have your cake and eat it too. I
> wouldn't settle for 'bool empty{}'.
>
> --------------------------------------------------
> bool empty {
> void set(auto value) { ... }
> auto get() { ... }
> }
>
> empty = false; // empty.set(false)
> auto b = empty; // auto b = empty.get()
> --------------------------------------------------
>
> for example, requires no hacks and no keywords. And has the added
> advantage
> that you can still use the getter and setter methods directly. To call
> them
> or get delegates from them.
>
I agree, this is a better solution!
More information about the Digitalmars-d
mailing list