DMD 1.007 release
Hasan Aljudy
hasan.aljudy at gmail.com
Wed Feb 21 01:26:20 PST 2007
Walter Bright wrote:
> Cleanup of compile time function execution issues.
>
> http://www.digitalmars.com/d/changelog.html
>
> http://ftp.digitalmars.com/dmd.1.007.zip
Is there a reason why this shouldn't work?! It seems to me this is the
most basic usage for mixin & compile time functions.
--------------------
import std.stdio;
void main()
{
writefln( getstruct( "test_struct", "int x; int y;" ) );
}
mixin( getstruct( "test_struct", "int x; int y;" ) );
char[] getstruct( char[] name, char[] sbody )
{
return "struct " ~ name ~ " { " ~ sbody ~ " }";
}
----------------
Compiling this, I get:
meta.d(8): Error: cannot evaluate getstruct("test_struct","int x; int
y;") at compile time
attribute argument to mixin must be a string, not
(getstruct("test_struct","int x; int y;"))
when I comment out the mixin() line, it compiles, and when I run the
program it outputs:
struct test_struct { int x; int y; }
More information about the Digitalmars-d-announce
mailing list