property syntax strawman

Sjoerd van Leent svanleent at gmail.com
Tue Aug 4 05:54:52 PDT 2009


Andrei Alexandrescu Wrote:

> Nick Sabalausky wrote:
> > "Walter Bright" <newshound1 at digitalmars.com> wrote in message 
> > news:h53g3i$elk$1 at digitalmars.com...
> >>   bool empty { ... }
> >>   void empty=(bool b) { ... }
> >>
> >> What do you think?
> > 
> > I think that if D starts to make a habit of aping the ugly C++ approach to 
> > adding new features (as this does), then we may as well just use C++. 
> 
> Let's not forget that C++ got very conservative about adding keywords 
> after a keyword spree (class that is essentially same as struct, 
> namespace, xyz_cast, oh yes typename, and, or, not plus other useful 
> names that I probably forgot). We don't want to get there.
> 
> 
> Andrei

I understand your point of view, but I am afraid that using an awkward syntax makes things difficult to understand. However, I could certainly live with the current proposal. But this has to do that I'm not afraid of symbolic ways to achieve something. Others might find it more difficult.

I think that a setter and a getter are two different things, but I would avoid to have an inconsistent property, such as setting an int and getting a bool, or something similar. Perhaps a compiler check could intercept?

But I think I can do it with the keywords that we already have in our possession:

bool in empty
{
}

bool out empty
{
}

Although perhaps this could be argued against, as in and out are used for contract programming. But this clearly is a different use.



More information about the Digitalmars-d mailing list