Properties
Nick Sabalausky
a at a.a
Mon Jan 12 08:31:03 PST 2009
"Frits van Bommel" <fvbommel at REMwOVExCAPSs.nl> wrote in message
news:gkfmr2$1n9j$1 at digitalmars.com...
> Nick Sabalausky wrote:
>> void func(ref int x) {...}
>> func(foo.aProperty);
>>
>> void func(int* x) {...}
>> func(&foo.aProperty);
>>
>> *Should* work with both variables and properties (but might need some
>> thinking in how to actually pull it off correctly. Someone mentioned C#
>> just doesn't even bother with it.)
>
> That just can't work without radically changing what a pointer is.
> Disallowing pointers to properties is really the best fix.
>
> If you really wanted, you might be able to wrap a getter/setter pair into
> a struct and pass that instead (and have default getter/setter templates
> for non-properties).
> It's probably easier to just pass in getter/setter delegates explicitly
> though.
What if properties were internally defined to be a struct of two delegates
(and maybe the internal value)? Although that would still leave an issue of
compatibility between int* and (property int)*, and might prevent the
intrnal value from being optimized away...
More information about the Digitalmars-d
mailing list