On 2012-02-21 20:53, Ali Çehreli wrote:
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
And the correct syntax for mixing in the template would be:
mixin helpMe!();
Or
mixin helpMe; // works if the template doesn't take any arguments
--
/Jacob Carlborg