On 01/31/2013 03:10 AM, TommiT wrote:
I think my former unholy union of namespace and variable is just too
confusing to reason about, so here's my new way of seeing effectively
the same thing, but with simpler semantics:

Keyword property is like the keyword struct, except:

1) properties can't have data members
2) properties can't have static member functions
3) properties can't have constructors/destructors
4) property instances always point to null
5) property instances' size is 0
6) if a property is declared inside a class/struct, all its
    member functions receive an implicit 'outer' variable
    which references the encapsulating object. Whether or
    not 'outer' is const ref or ref depends only on the
    constness of the encapsulating object.

Example:
...
Usage:

T t;
int v = t.myProp; // lowers to t.myProp.getIt due to alias this
t.myProp = 41;
t.myProp += 1;
assert(t.myProp.isCorrect());
assert(&t.myProp == null);
assert(T.PropType.sizeof == 0);

auto v = t.myProp; // ?

Reply via email to