digitalmars.D.bugs - [Issue 9551] New: template this parameter not recognized in constructors
- d-bugmail puremagic.com (71/71) Feb 20 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9551
- d-bugmail puremagic.com (7/15) Feb 20 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9551
- d-bugmail puremagic.com (8/19) Feb 20 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9551
- d-bugmail puremagic.com (13/28) Feb 20 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9551
- d-bugmail puremagic.com (8/33) Feb 20 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9551
- d-bugmail puremagic.com (7/10) Feb 20 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9551
- d-bugmail puremagic.com (8/14) Feb 20 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9551
- d-bugmail puremagic.com (8/18) Feb 20 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9551
- d-bugmail puremagic.com (12/13) Feb 20 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9551
- d-bugmail puremagic.com (8/14) Feb 20 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9551
http://d.puremagic.com/issues/show_bug.cgi?id=9551 Summary: template this parameter not recognized in constructors Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: gor.f.gyolchanyan gmail.com 07:36:56 PST --- The template this parameter, which works fine for normal methods: class Base { string label; this(string label_) { label = label_; } string toString(this This_)() { return This_.stringof ~ "(`" ~ label ~ "`)"; } } class Derived: Base { this() { super("Hello, world!"); } } unittest { Derived d = new Derived(); assert(d.toString() == "Derived(`Hello, world!`)"); } doesn't work for constructors: class Base { this(this This_)() { // Build a dispatch table using __traits(allMethods, This_) } void opCall(Payload_)(Payload_ payload_) { // Dynamically dispatch payload_ using the previously built dispatch table. } } class Derived: Base { // implicitly generated constructor will call the Base.this() and implicitly give it the static type of Derived. } unittest { Base b = new Derived; b(); // 100% transparent dynamic dispatch } Because of the following compile-time errors: C:\Users\g.gyolchanyan\Desktop\test.d(3): Error: found 'This_' when expecting ')' C:\Users\g.gyolchanyan\Desktop\test.d(3): Error: semicolon expected following function declaration C:\Users\g.gyolchanyan\Desktop\test.d(3): Error: Declaration expected, not ')' -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 20 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9551Because of the following compile-time errors: C:\Users\g.gyolchanyan\Desktop\test.d(3): Error: found 'This_' when expecting ')' C:\Users\g.gyolchanyan\Desktop\test.d(3): Error: semicolon expected following function declaration C:\Users\g.gyolchanyan\Desktop\test.d(3): Error: Declaration expected, not ')'As far as I see, it conflicts with postblit syntax `this(this)`. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 20 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9551 08:15:30 PST ---Yes, it definitely looks like it, but the existence of a type name after "this" in the template parameter list should disambiguate it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------Because of the following compile-time errors: C:\Users\g.gyolchanyan\Desktop\test.d(3): Error: found 'This_' when expecting ')' C:\Users\g.gyolchanyan\Desktop\test.d(3): Error: semicolon expected following function declaration C:\Users\g.gyolchanyan\Desktop\test.d(3): Error: Declaration expected, not ')'As far as I see, it conflicts with postblit syntax `this(this)`.
Feb 20 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9551But, it is not just only a parser problem. Constructor will be treated specially for object construction entry. And, unfortunately, language semantics between non-mutable object construction and qualified constructor is yet not defined well. The combination of TemplateThisParameter and constructor may touch similar *yet not defined semantics*. Therefore, I must say that this issue will not be fix soon. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------Yes, it definitely looks like it, but the existence of a type name after "this" in the template parameter list should disambiguate it.Because of the following compile-time errors: C:\Users\g.gyolchanyan\Desktop\test.d(3): Error: found 'This_' when expecting ')' C:\Users\g.gyolchanyan\Desktop\test.d(3): Error: semicolon expected following function declaration C:\Users\g.gyolchanyan\Desktop\test.d(3): Error: Declaration expected, not ')'As far as I see, it conflicts with postblit syntax `this(this)`.
Feb 20 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9551 08:31:09 PST ---This is extremely unfortunate, because this is the only way that I know of to implement transparent dynamic dispatch. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------But, it is not just only a parser problem. Constructor will be treated specially for object construction entry. And, unfortunately, language semantics between non-mutable object construction and qualified constructor is yet not defined well. The combination of TemplateThisParameter and constructor may touch similar *yet not defined semantics*. Therefore, I must say that this issue will not be fix soon.Yes, it definitely looks like it, but the existence of a type name after "this" in the template parameter list should disambiguate it.Because of the following compile-time errors: C:\Users\g.gyolchanyan\Desktop\test.d(3): Error: found 'This_' when expecting ')' C:\Users\g.gyolchanyan\Desktop\test.d(3): Error: semicolon expected following function declaration C:\Users\g.gyolchanyan\Desktop\test.d(3): Error: Declaration expected, not ')'As far as I see, it conflicts with postblit syntax `this(this)`.
Feb 20 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9551This is extremely unfortunate, because this is the only way that I know of to implement transparent dynamic dispatch.Couldn't you use helper function for the construction? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 20 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9551 08:39:22 PST ---Theoretically, I could, but it would require immense boilerplate when dealing with large class hierarchies, which is hard to enforce. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------This is extremely unfortunate, because this is the only way that I know of to implement transparent dynamic dispatch.Couldn't you use helper function for the construction?
Feb 20 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9551I cannot imagine the 'immense boilerplate', but sorry it would need for a while. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------Theoretically, I could, but it would require immense boilerplate when dealing with large class hierarchies, which is hard to enforce.This is extremely unfortunate, because this is the only way that I know of to implement transparent dynamic dispatch.Couldn't you use helper function for the construction?
Feb 20 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9551 Steven Schveighoffer <schveiguy yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |schveiguy yahoo.com 09:01:14 PST ---As far as I see, it conflicts with postblit syntax `this(this)`.Does it? postblit does not have the extra parentheses which is the signature of a template method. I'm asking out of ignorance. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 20 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9551I'm saying that _currently_ they are confused, and should be properly distinguished. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------As far as I see, it conflicts with postblit syntax `this(this)`.Does it? postblit does not have the extra parentheses which is the signature of a template method. I'm asking out of ignorance.
Feb 20 2013