DIP4: Properties

Chad J chadjoan at __spam.is.bad__gmail.com
Sat Jul 25 14:11:00 PDT 2009


Andrei Alexandrescu wrote:
> Chad J wrote:
>> I really like this idea.
> 
> Which?
> 
> Andrei

That whole post I replied to.

>     int foo.opIndex(int); // foo[1];
>     void foo.opAddAssign(int); / foo += 1;
>     void foo.invert(); // special function attached to property 

Or as I see it working in the more verbose case:

T foo.opAssign(T bar)
{
	// code goes here.
}

If namespaces lead to that kind of ability then they seem pretty nifty.

>     namespace foo {
>         int opGet(); // getter
>         void opAssign(int); // setter
>         ...
>         int opIndex(int); // foo[1];
>         void opAddAssign(int); / foo += 1;
>         void invert(); // special function attached to property
>     } 

That seems pretty useful.  Maybe it doesn't have to be namespace.  Use
scope or auto instead.  scope seems appropriate, though it may be asking
for ambiguities.  I can live without this though if it is too drastic.



More information about the Digitalmars-d mailing list