Another Properties Proposal

BCS BCS at pathlink.com
Tue Aug 21 16:22:02 PDT 2007


Chad J wrote:
> OK how about this:
> 
[...]
> 
> In this incantation, properties are a compile-time construct.
> It just tells the compiler that we have something called "foo" which is
> really a pair of functions, but we want it to behave exactly like a data 
> field.
> 

How about allow it like this:

property Type Name{ ListOfFunctions };

where ListOfFunctions may contain one "Type fn(void)" and any number of 
"Type/void fn(Type2)" so long as the overload rules can unambiguously 
select one of them for all types. The value of an assignment to a 
property would be the return, if any, of the given function. The value 
of the property as a strict R-value would be the fn(void), if it exists. 
This wouldn't work exactly like a member but, with a little care, would 
be darn close.

I like the override of opXxxAssign to.

[...]
> - Chad



More information about the Digitalmars-d mailing list