Reddit: why aren't people using D?
Bill Baxter
wbaxter at gmail.com
Thu Jul 23 14:13:13 PDT 2009
On Thu, Jul 23, 2009 at 1:53 PM, Michiel
Helvensteijn<m.helvensteijn.remove at gmail.com> wrote:
> Lutger wrote:
>
>> There have been a lot of discussions on this topic in the past but I can't
>> recall any conclusions. Perhaps some brave soul would dare to write a DIP
>> on properties?
>
> Property DIPs have been offered in the newsgroup in the past, only before
> they were called DIPs. I also offered a possible design:
>
> http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=81759
>
> Feel free to modify and/or DIPify it.
"""
I've always thought properties should work somewhat like this:
property int length {
get() { return this.len; }
set(newLen) { this.len = newLen; }
}
"""
I'm curious. Is it just a coincidence that how you've "always
thought" happens to look a lot like C# properties? Or did you mean
to say "Ever since I saw how C# does properties I've thought...."?
In any event I think a problem with this is that for D's simple
grammar to remain simple and context free, get and set would both have
to be made keywords in the language. Can a compiler guru confirm
that? Not a big issue, but introducing 3 keywords for this one
feature will be a tough sell. Perhaps just
property int length {
() { return this.len; }
(newLen) { this.len = newLen; }
}
would be enough. Maybe I'm wrong about get/set being an issue, though.
--bb
More information about the Digitalmars-d
mailing list