Feature request - simpler constructors
Robert Fraser
fraserofthenight at gmail.com
Thu Sep 20 11:34:58 PDT 2007
On the other hand, this way you could do some best things like requiring a particular subclass to be assigned to a sipreclass type (useful if you have two related class hierarchies.
Steven Schveighoffer Wrote:
>
> "Bill Baxter" wrote
> > I like the idea but I'm not wild about the syntax you've chosen. I'd like
> > to be able to read off the types of the parameters from the function
> > signature without having to dig around in the class for where the memebers
> > are defined. What about something like prefixing the name with a dot?
> >
> >
> > this(int .year, int .month, int .day, int .hour, int .minute, int
> > .second)
>
> Personally, I like Janice's idea better. It should be up to the IDE to tell
> you what the types are for the constructor.
>
> Imagine a situation like this:
>
> class X
> {
> int y;
> this(int .y) {}
> }
>
> Now the author decides y should be a long:
>
> class X
> {
> long y;
> this(int .y) {}
> }
>
> Oops, forgot to update the constructor. But the compiler won't complain
> because this.y = y is valid. With Janice's syntax, this doesn't happen.
>
> -Steve
>
>
More information about the Digitalmars-d
mailing list