digitalmars.D.bugs - [Issue 1903] New: Template declaration (for mixin) can't be parsed
- d-bugmail puremagic.com (26/26) Mar 10 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1903
- d-bugmail puremagic.com (10/10) Mar 10 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1903
- d-bugmail puremagic.com (4/4) Mar 10 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1903
- downs (4/38) Mar 10 2008 The problem is that a template basically constitutes a namespace, not a ...
- Russell Lewis (2/43) Mar 10 2008 I refactored it to use string mixins. It works now, but it's ugly.
- Robert Fraser (3/50) Mar 10 2008 Well, AST macros are a planned feature. In fact, there's already a
- Bill Baxter (4/8) Mar 10 2008 Had me excited there for a minute. The macro.c currently in the source
- d-bugmail puremagic.com (13/13) Nov 20 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1903
http://d.puremagic.com/issues/show_bug.cgi?id=1903 Summary: Template declaration (for mixin) can't be parsed Product: D Version: 2.012 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: webmaster villagersonline.com DMD 2.012 Linux The following code doesn't work, and if I understand correctly, it should: BEGIN CODE void Foo(int a,int b) {} template Bar(int x) { Foo(x,x); } void Baz() { mixin Bar!(1); } END CODE --
Mar 10 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1903 I should have given more details on how it fails. It appears to fail on the , character in the template declaration: test.d(4): found ',' when expecting ')' test.d(4): semicolon expected, not 'x' test.d(4): no identifier for declarator x test.d(4): semicolon expected, not ')' test.d(4): Declaration expected, not ')' --
Mar 10 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1903 I don't think you can mixin statements, only decelerations. --
Mar 10 2008
d-bugmail puremagic.com wrote:http://d.puremagic.com/issues/show_bug.cgi?id=1903 Summary: Template declaration (for mixin) can't be parsed Product: D Version: 2.012 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: webmaster villagersonline.com DMD 2.012 Linux The following code doesn't work, and if I understand correctly, it should: BEGIN CODE void Foo(int a,int b) {} template Bar(int x) { Foo(x,x); } void Baz() { mixin Bar!(1); } END CODEThe problem is that a template basically constitutes a namespace, not a scope. :) So you can only put stuff in a template that you could also put at the global module level. --downs
Mar 10 2008
downs wrote:d-bugmail puremagic.com wrote:I refactored it to use string mixins. It works now, but it's ugly.http://d.puremagic.com/issues/show_bug.cgi?id=1903 Summary: Template declaration (for mixin) can't be parsed Product: D Version: 2.012 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: webmaster villagersonline.com DMD 2.012 Linux The following code doesn't work, and if I understand correctly, it should: BEGIN CODE void Foo(int a,int b) {} template Bar(int x) { Foo(x,x); } void Baz() { mixin Bar!(1); } END CODEThe problem is that a template basically constitutes a namespace, not a scope. :) So you can only put stuff in a template that you could also put at the global module level. --downs
Mar 10 2008
Russell Lewis wrote:downs wrote:Well, AST macros are a planned feature. In fact, there's already a macro.c in DMD2's front-end source code :-).d-bugmail puremagic.com wrote:I refactored it to use string mixins. It works now, but it's ugly.http://d.puremagic.com/issues/show_bug.cgi?id=1903 Summary: Template declaration (for mixin) can't be parsed Product: D Version: 2.012 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: webmaster villagersonline.com DMD 2.012 Linux The following code doesn't work, and if I understand correctly, it should: BEGIN CODE void Foo(int a,int b) {} template Bar(int x) { Foo(x,x); } void Baz() { mixin Bar!(1); } END CODEThe problem is that a template basically constitutes a namespace, not a scope. :) So you can only put stuff in a template that you could also put at the global module level. --downs
Mar 10 2008
Robert Fraser wrote:Had me excited there for a minute. The macro.c currently in the source is for expansion of DDoc macros. --bbI refactored it to use string mixins. It works now, but it's ugly.Well, AST macros are a planned feature. In fact, there's already a macro.c in DMD2's front-end source code :-).
Mar 10 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1903 smjg iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smjg iname.com Status|NEW |RESOLVED Resolution| |INVALID Please don't blindly quote the entire message when replying. It's bad enough on any newsgroup, and when it clutters up Bugzilla, it's even worse. A template by syntax contains declarations, not statements. So this isn't supposed to work. --
Nov 20 2008