digitalmars.D.bugs - [Issue 2030] New: String mixin within teplatate mixin doesn't compile
- d-bugmail puremagic.com (26/26) Apr 24 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2030
- d-bugmail puremagic.com (28/28) Apr 24 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2030
- Janice Caron (4/5) Apr 24 2008 Shouldn't that be
- d-bugmail puremagic.com (5/5) Apr 25 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2030
http://d.puremagic.com/issues/show_bug.cgi?id=2030 Summary: String mixin within teplatate mixin doesn't compile Product: D Version: 2.013 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: bartosz relisoft.com The following code doesn't compile: template foo (string init) { mixin ("string str = \"" ~ init ~ "\";"); } mixin (foo !("hello")); attribute argument to mixin must be a string, not (foo!("hello")) Analogous code without a string mixin works: template bar (string s) { string str = s; } mixin bar!("hello"); --
Apr 24 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2030 ary esperanto.org.ar changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID No, the analogous code is template bar (string s) { string str = s; } mixin (bar!("hello")); and it doesn't compile (and it shouldn't). Notice the parenthesis after mixin. There's a difference between mixin something; and mixin (something); The first one is a template mixin (http://digitalmars.com/d/1.0/template-mixin.html), the second one is a mixin (http://www.digitalmars.com/d/1.0/mixin.html). This compiles correctly: template bar (string s) { string str = s; } mixin bar!("hello"); --
Apr 24 2008
On 24/04/2008, d-bugmail puremagic.com <d-bugmail puremagic.com> wrote:mixin (foo !("hello"));Shouldn't that be mixin foo!("hello"); i.e. without the extra pair of parentheses?
Apr 24 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2030 Yes, it's a parentheses problem. Shows you that making two completely different constructs in a language differ only be parentheses is confusing. --
Apr 25 2008