property syntax strawman

Michel Fortin michel.fortin at michelf.com
Mon Aug 3 08:35:39 PDT 2009


On 2009-08-03 11:03:54 -0400, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

> Now that I think of it, even if properties don't readily return 
> delegates, they are trivially easy to obtain:
> 
> class A
> {
>      ... define property foo with whatever syntax ...
> }
> 
> unittest
> {
>      auto a = new A;
>      auto getter = () { return a.foo; }
>      auto setter = (int x) { a.foo = x; }
>      setter(5);
>      writeln(getter());
> }
> 
> I actually compiled and ran that with foo defined as a regular field.

They're indeed very easy to obtain, and using this method improves 
compatibility with regular fields, so it's great.

That said, can you see the property through reflection?

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list