dynamic classes and duck typing
Bill Baxter
wbaxter at gmail.com
Mon Nov 30 18:12:51 PST 2009
On Mon, Nov 30, 2009 at 6:03 PM, Walter Bright
<newshound1 at digitalmars.com> wrote:
> Bill Baxter wrote:
>>
>> Also how does this interact with property syntax?
>
> Define opDispatch with @property.
So we can overload on @property-ness? I.e. this works
struct S
{
@property
float x() { return 1.0f; }
float x() { return 2.0f; }
}
void main()
{
S s;
writefln("%s", s.x); // writes 1.0
writefln("%s", s.x()); // writes 2.0
}
--bb
More information about the Digitalmars-d
mailing list