Possible @property compromise

TommiT tommitissari at hotmail.com
Wed Jan 30 08:26:44 PST 2013


On Wednesday, 30 January 2013 at 15:10:37 UTC, Jacob Carlborg 
wrote:
> I really don't see much point in properties/methods that just 
> forwards to an instance variable.

I assume you mean something like this:

struct S
{
     private T _t;

     ref T get() { return _t; }

     void set(T t) { ... }
}

The benefit of the above type of coding versus having a public T 
variable, is that you can change the implementation of S without 
changing S's interface. Perhaps I would like to change it to this 
(or whatever):

private static T[5] tees;

struct S
{
     private byte _idx;

     ref T get() { return tees[_idx]; }

     void set(T t) { ... }
}


More information about the Digitalmars-d mailing list