opStar

BCS ao at pathlink.com
Mon Nov 12 08:13:39 PST 2007


Reply to Janice,

> On Nov 12, 2007 2:19 AM, Walter Bright <newshound1 at digitalmars.com>
> wrote:
> 
>> Adding new properties is a pretty disruptive thing to do, especially
>> common names.
>> 
> I agree. If you were going to introduce a new property, I'd be the
> /first/ to argue that it shouldn't be called something as common as
> "value". There are plenty of less common alternatives.
> 
> But that said, it wouldn't be my first choice. My first choice would
> be to have the dot operator automatically call opDeref as many times
> as necessary, so that iterators behave like pointers.
> 


struct S1
{
 int a;
}


struct S2
{
 int c;
 S1 opDeref();
}


struct S3
{
 int b;
 S2 opDeref();
}


struct S4
{
 int d;
 S3 opDeref();
}


S4 s;

s.a; //-> a.opDeref.opDeref.opDeref.a
s.b; //-> a.opDeref.b
s.c; //-> a.opDeref.opDeref.c
s.d; //-> a.d


this causes some odd "tiny changes make huge differences" issues along with 
another hijacking case.

I'm just saying these need to be considered, not that they are killers to 
the idea.





More information about the Digitalmars-d mailing list