property-like data members

Steven Schveighoffer schveiguy at yahoo.com
Mon Jan 3 05:34:42 PST 2011


On Sun, 02 Jan 2011 05:29:48 -0500, spir <denis.spir at gmail.com> wrote:

> Hello,
>
> Using properties allows travesting a method call into direct data  
> access. What if the underlying member actually is plain data? Would it  
> be possible to provide a real data member where the language expects a  
> property (for instance as range empty & front properties)?

Yes, just use a data member:

struct MyRange {
    int front;
    bool empty;
    void popFront();
}

A property is actually supposed to work just like a field.

There is no need for new syntax.

-Steve


More information about the Digitalmars-d mailing list