mixin template FAIL

Ali Çehreli acehreli at yahoo.com
Tue Feb 21 11:53:17 PST 2012


On 02/21/2012 10:47 AM, Zach the Mystic wrote:
 > I decided to try using template mixin, but even the simplest program
 > fails. What's wrong with this code? Error list follows.
 > DMD64 D Compiler v2.057 OSX 10.6
 >
 > import std.stdio;
 >
 > mixin template helpMe()
 > {
 > writeln("Satisfying!");
 > }
 >
 > void main()
 > {
 > mixin helpMe();
 > }
 >
 > test.d(5): unexpected ( in declarator
 > test.d(5): basic type expected, not "Satisfying!"
 > test.d(5): found '"Satisfying!"' when expecting ')'
 > test.d(5): no identifier for declarator writeln(int)
 > test.d(5): semicolon expected following function declaration
 > test.d(5): Declaration expected, not ')'
 > test.d(10): ';' expected after mixin
 > test.d(10): found ')' instead of statement
 >

According to the docs, template mixins can have only declarations but 
helpMe above has a statement.

   http://dlang.org/template-mixin.html

Ali



More information about the Digitalmars-d-learn mailing list