On Sat, 21 Jun 2014 18:50:21 +0000
Xinok via Digitalmars-d <digitalmars-d@puremagic.com> wrote:

> On Saturday, 21 June 2014 at 17:17:57 UTC, Suliman wrote:
> > Dart and few others modern languages support short declaration
> > constructor with parameter:
> >
> > class Person {
> >   String name;
> >
> >   Person(String name) {
> >     this.name = name;
> >   }
> > }
> >
> > // Shorter alternative
> > class Person {
> >   String name;
> >
> >   // parameters prefixed by 'this.' will assign to
> >   // instance variables automatically
> >   Person(this.name);
> > }
> >
> > it's there any DIP for adding this future to D?
>
> I'd prefer that we didn't crowd the language with minor shortcuts
> like these, and save syntactic sugar for more useful features.
> Plus, it would be easy enough to make a string mixin which
> generates such boilerplate code.

Agreed. This would just add more stuff to the language that people would have
to understand, and it really doesn't add much benefit. It's just a slightly
terser syntax - and one that doesn't fit in with any other kind of function
declarations in D to boot.

- Jonathan M Davis

Reply via email to