property syntax strawman

Marianne Gagnon auria.mg at gmail.com
Sun Aug 2 10:20:21 PDT 2009


Ah, and also :

Andrei Alexandrescu Wrote:

> Marianne Gagnon wrote:
> > Like someone else pointed out, existing keywords could be reused :
> > 
> > bool empty
> > {
> >     in(bool value)
> >     {
> >         _my_empty = value;
> >     }
> >     out
> >     {
> >         return _my_empty;
> >     }
> > }
> > 
> > I like this quite a bit.  I never wrote any compiler, granted, but I don't think it'd be that hard to implement - and doesn't introduce any new keyword.
> 
> Please, please, could we look at something that does NOT go through two 
> scopes to get to the code?
> 

Sure, that was just an exampel of keyword re-use, you can do the exact same without scores :

out int foo()
{
    return  m_foo;
}
in int foo(int value)
{
    m_foo = foo;
}

Many variations possible on this theme ;) So not wanting a new keyword is not a show-stopper for solutions involving the use of keywords, in and out can be used there with no ambiguity i can think of (maybe others will though)



More information about the Digitalmars-d mailing list