On 2013-14-02 10:02, TommiT <[email protected]> wrote:

I propose we just forget about the whole concept of a property, and instead add to D a new construct called 'memberspace'. Memberspace subdivides the 'space' in which the member functions and operators of a type live into separately named 'subspaces', like namespaces do for freestanding functions and classes in C++. Read more about the uses of this idea over there (it's not my idea):

http://accu.org/index.php/journals/1527

Here's how it could look like:

struct S
{
     int _value;

     memberspace space1
     {
         int opCall() const
         {
             return _value;
         }

         void opAssign(int v)
         {
             _value = v;
         }

         void method() const { }
     }

     memberspace space2
     {
         static int opCall()
         {
             return 123;
         }
     }
}

void main()
{
     S var;
     var.space1 = 42;
     assert(var.space1() == 42);
     assert(S.space2() == 123);
     var.space1.method();

     int n1 = var.space1; // error
     int n2 = S.space2;   // error
}

Now, imagine replacing the name of your memberspace with the name of the thing you used to call a 'property'.

This seems to be basically what I outlined in issue 5158[1].


[1] http://d.puremagic.com/issues/show_bug.cgi?id=5158

--
Simen

Reply via email to