property / getProperty() / setProperty()

Jarrett Billingsley jarrett.billingsley at gmail.com
Sat Aug 1 14:38:46 PDT 2009


On Sat, Aug 1, 2009 at 4:01 PM, Michel Fortin<michel.fortin at michelf.com> wrote:

>> 3. There is no naming ambiguity.
>
> A set/get prefix removes pretty much all ambiguity too.
>
> I mean, the current syntax is "T transform()" and you can't know if
> transform is a noun or a verb. With my prefix it's "T getTransform()" which
> makes it pretty clear what it does. With yours it's "property T transform()"
> and it's pretty clear too.

class X
{
    int foo;
    int getFoo() { return 5; }
    int blah() { return foo; /* um.. which? */ }
}

> And to compensate that +1 for you above, I'd point out that there is an
> alternative with no case issue (get_thing/set_thing) and that your proposal
> requires a keyword.

Then let's introduce annotations and be done with it.  No more pure,
shared, __gshared, nothrow, and probably a whole slew of other silly
attribute keywords.

> About your idea, I find it confusing that (&something) and &(something) may
> not have the same meaning.

That's true.  Then again, how often do you need to get the address of
a returned ref value?



More information about the Digitalmars-d mailing list