UDP enhancement
Daniel Murphy
yebblies at nospamgmail.com
Tue Jul 2 18:42:07 PDT 2013
"Kapps" <opantm2+spam at gmail.com> wrote in message
news:zroaabiwkaxqybrtdhxp at forum.dlang.org...
>
> As someone who uses properties almost everywhere, and almost never uses
> public fields, this is one of my biggest gripes with D remaining. It's
> incredibly annoying to have to do things like
>
> private int _width;
> /// Gets or sets the total width, in pixels, of this control.
> @property int width() const {
> return _width;
> }
> /// ditto
> @property void width(int value) {
> this._width = value;
> }
>
>
> Something like
>
> /// Gets or sets the total width, in pixels, of this control.
> @property const int width;
>
> Is just so much nicer and saves so much bloat. I feel like the current
> property syntax is one of those places where IDE code snippets will start
> to become, not necessary, but extremely useful. It's the type of manual
> repetition that D aims to avoid, but in this case fails at.
> I don't know if I agree with automatically expanding to const though. I'd
> like to be able to do '@property Control parent' without needing to return
> a const(Control) because the property is expanded to be const. Although if
> we had a virtual keyword, final is something that I think should be
> default for properties, and I think it's a mistake that the current
> @property doesn't infer final in the first place. Safe and nothrow are two
> assumptions that are probably quite safe to assume for the most part as
> well.
You should probably try using template mixins, if all you need to do is
expand some code.
More information about the Digitalmars-d
mailing list