property syntax strawman

Frank Benoit keinfarbton at googlemail.com
Sun Aug 2 03:03:16 PDT 2009


Walter Bright schrieb:
> Zhenyu Zhou wrote:
>> Walter Bright Wrote:
>>> but oops! That defines a field. So we came up with essentially a hack:
>>>
>>>    bool empty{}
>>
>> weird syntax
> 
> I agree, it's a wart.
> 
> 
>> I'd rather use
>>    bool empty=() { ... }
>>    void empty=(bool b) { ... }
> 
> I suggested that, but Andrei thought it looked unintuitive, and he has a
> point.

Or how about making it a single method?

bool empty=(bool* value){
	if( value ) _empty = *value;
	return _empty;
}

The compiler rewrites the calling code to either pass the address or null.



More information about the Digitalmars-d mailing list