new DIP5: Properties 2

Kagamin spam at here.lot
Tue Jul 28 01:57:57 PDT 2009


Andrei Alexandrescu Wrote:

> > I know you said you didn't
> > really like the idea of having to name your range's empty function
> > 'opGet_empty'.
> 
> Correct. I'd rather try to disambiguate the rather rare case when a 
> property returns a delegate etc. For me, I get a breath of fresh air 
> whenever I get to not write "()". I can't figure how some are missing it.

It's agains C look and feel to call function without braces. It's not a problem to write code. It's a problem to read and understand it, isn't it? Isn't current programming techniques development aimed to ease maintenance?

> > The property attribute also has the nice property
> > (heh) that you can call the property setters and getters either as
> > properties or as functions (i.e. "r.empty" or "r.empty()").
> > Basically, the behavior would be *exactly* as it is now, except you'd
> > have to explicitly state with which functions it would be legal.
> 
> I guess I'd rather not have to specify that. I'd do that on all of my 
> functions that don't take parameters. To me that's syntactic noise and 
> an unnecessary special case.

r.empty returns an empty instance of a range (especially makes sense for dummy objects). r.empty() empties the range. It's not quite good if your code has such an ambiguity.



More information about the Digitalmars-d mailing list