On Saturday, 10 August 2013 at 17:48:34 UTC, BLM768 wrote:
On Saturday, 10 August 2013 at 10:29:51 UTC, Stian Pedersen wrote:
To add to the mess - or maybe suggest a new approach, what about:

class A
{
   int foo();
   void foo=(int a);
   private foo_;
}

Then a.foo = 42; calls the foo= method. No other conversions from a=b to a method invocation.

It may be suggested in one of these 46 pages which I haven't read. And it'll probably break a lot of stuff.

The problem with this approach is that the getter is still operating under the semantics of a method, but, as a property, it should be acting like a field. An approach like this would work:

class A {
Sorry; message got cut off when I tried to insert a tab and then pressed space with the "Send" button focused.

Continuing...

class A {
    @property int foo();
    @property void foo=(int a);
    //etc.
}

However, it doesn't offer any significant advantage over the current property syntax other than providing a clearer distinction between getters and setters, which is only important when dealing with UFCS, as pointed out in an earlier post.

Reply via email to