October 05, 2013 [Issue 9066] Add constructor inheritance feature | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=9066 --- Comment #10 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-10-05 09:59:19 PDT --- (In reply to comment #9) > (In reply to comment #8) > > Your example wouldn't compile. > You can't default construct a class that defines a non-default constructor even > though we do have implicit constructor inheritance. I'm not default-constructing a class in that example. > The rule here is very simple, if you define a constructor none is inherited. I see what you mean, that could work. Although I still want the ability to explicitly re-introduce base-class constructors via some syntax. So in essence we'll have: ----- class A { this(int); this(double); } class B : A { } // implicitly inherits ctors (very useful for Exception) ----- ----- class A { this(int); this(double); } class B : A { this(string); } // does *not* inherit ctors ----- I also want: ----- class A { this(int); this(double); } // inherit the this(int) ctor class B : A { this(string); alias super.this(int) this; } ----- However these two features can be implemented separately, so maybe we should split this up into two enhancement requests. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 05, 2013 [Issue 9066] Add constructor inheritance feature | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=9066 --- Comment #11 from Martin Nowak <code@dawg.eu> 2013-10-05 11:49:56 PDT --- (In reply to comment #10) > class A { this(int); this(double); } > > // inherit the this(int) ctor > class B : A { this(string); alias super.this(int) this; } > ----- This is more specific because you have to specify which constructor to inherit by stating the parameter types. So you will save less typing over this(int a) { super(a); }. It's still useful because you can reuse the default arguments and the compiler will check for you that the parameter types match the base class. No good idea for the syntax though. Maybe we can special case the alias syntax as you used it in the example. > so maybe we should split this up into two enhancement requests Makes sense. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 05, 2013 [Issue 9066] Add constructor inheritance feature | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=9066 --- Comment #12 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-10-05 12:10:51 PDT --- (In reply to comment #11) > This is more specific because you have to specify which constructor to inherit > by stating the parameter types. So you will save less typing over this(int a) { > super(a); }. I'm thinking it would save the binary size though (save on duplicated functions that do nothing but forward arguments). Especially if you use a mixin template to autogenerate these (for whatever reason). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 11, 2013 [Issue 9066] Add constructor inheritance feature | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=9066 --- Comment #13 from Martin Nowak <code@dawg.eu> 2013-10-11 09:59:26 PDT --- (In reply to comment #10) > I see what you mean, that could work. Although I still want the ability to explicitly re-introduce base-class constructors via some syntax. So in essence we'll have: I had an idea how to achieve more flexibility with only a single special case for alias this. - We add implicit constructor inheritance. - When you define a constructor implicit inheritance is disabled. - We special case alias super.this this for explicit inheritance, it is invalid currently and has no useful semantic meaning. It's semantic meaning is overload the super class constructors with the local constructors. - You can use @disable this(int) in the derived class to selectively disable some of the super class constructors. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 11, 2013 [Issue 9066] Add constructor inheritance feature | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=9066 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |k.hara.pg@gmail.com --- Comment #14 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-10-11 11:21:54 PDT --- (In reply to comment #13) > I had an idea how to achieve more flexibility with only a single special case for alias this. Sounds good to me. Kenji what are your thoughts? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation