Revised RFC on range design for D2

Sergey Gromov snake.scaly at gmail.com
Mon Sep 29 10:59:17 PDT 2008


Mon, 29 Sep 2008 12:23:58 -0500,
Andrei Alexandrescu wrote:
> Sergey Gromov wrote:
> > D has a simple rule for property methods.  This rule has side effects.  
> > If the side effects are so bad that a hack is required to counter them,
> > then the rule should be replaced with a better one.  Otherwise your hack 
> > will inevitably introduce new, less obvious side effects than those it 
> > were supposed to fight, and will finally require other hacks.
> > 
> > struct Range
> > {
> >   ref int head() {...}
> > }
> > Range r;
> > r.head = 5; // error
> 
> A function can return an object that allows assignment even today with 
> opAssign.

Today the compiler tries to call Range.head with one argument and fails.  
Another side effect needs hacking.

> I said "If you can call: entity.prop(entity.prop); then you can consider 
> prop a property, period." I did not say "If and only if".


More information about the Digitalmars-d-announce mailing list