On Wed, 14 Dec 2011 02:36:43 -0000, Michel Fortin <michel.for...@michelf.com> wrote:

On 2011-12-13 23:08:43 +0000, Andrei Alexandrescu <seewebsiteforem...@erdani.org> said:

We could have inferred property intention from the code pattern, without requiring any keyword. That solution (which was discussed and rejected in this newsgroup) was miles ahead from the drivel of @property we have now.

By "code patterns", you mean something like this?

        struct Foo
        {
                int getBar();
                void setBar(int);
        }

        void main()
        {
                Foo foo;
                int a = foo.bar;  // calls getBar()
                foo.bar = a;      // calls setBar(a)
        }

Why not something similar to C# syntax...

struct Foo
{
int bar // <- does DMD do lookahead? detect { instead of ; here and trigger "property" parsing
  {
    get
    {
      return value;  // <- 'value' meaning the value of the 'bar' member
    }
    set
    {
this = value; // <- 'this' meaning the 'bar' member, 'value' meaning the RHS of the "£instance.bar = <value>" statement
    }
  }
}

Regan

Reply via email to