Reddit: why aren't people using D?
Steven Schveighoffer
schveiguy at yahoo.com
Sun Jul 26 09:50:24 PDT 2009
On Fri, 24 Jul 2009 22:58:33 -0400, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> Rainer Deyke wrote:
>> Ary Borenszweig wrote:
>>> Maybe what scares Walter is a whole new syntax for properties. If at
>>> least you could say which functions are properties and which are not,
>>> that would be a small change and it'll make it possible for other
>>> things. Something like:
>>>
>>> int property foo(); // getter
>>> int property foo(int value); // setter
>> My proposal requires no new keywords and no new syntax:
>> int getfoo(); // getter
>> int setfoo(int); // setter
>
> This is pretty clean, and in keep with the opXxx approach. Actually how
> about defining property foo by defining opGet_foo and opSet_foo.
I would be OK with defining properties any of these ways. Although the
definition of properties is ugly, it's the usability and meaning which are
most important. Using opGet and opSet is probably the better method,
since nobody is going to name their normal members that way.
In fact, I think C++.Net did something similar in earlier versions.
Something like to call or define properties you defined the function
get_propname and set_propname.
-Steve
More information about the Digitalmars-d
mailing list