On Wednesday, 30 January 2013 at 18:36:17 UTC, Dmitry Olshansky
wrote:
[...]
I have one key problem - the hidden pointer detail.
In other words how should it find the instance of the outer
struct to to access it?
struct A{
int a;
struct B{
void foo(){ a = 42; }
}
B b;
}
A a;
a.b.foo(); //how that b is supposed to know it's outer struct
without the hidden pointer?
auto x = a.b;
x.foo();// and now what?
Good point.
A property-struct could behave like a struct and also like a
regular member function.
Member functions work because they take in a pointer to the
struct or class when called, eg
a.b.foo();
becomes
a.b.foo(&a);
auto x = a.b; // returns property value of b, not b itself.
auto x = &a.b; // returns delegate pointer to b
x.foo(); // OK
--rt