mixin D code into D code
Daniel919
Daniel919 at web.de
Tue Feb 6 11:39:11 PST 2007
Hi, why not use D instead of perl ?
Since "sh style script syntax" is supported, I would like the following to be possible:
import std.stdio, std.string, std.metastrings;
void foo(A...)(A a)
{
writefln(format(typeid(typeof(a[1]))) ~ " " ~ a[0] ~ " = \"" ~ a[1] ~ "\"");
}
void main (char[][] args)
{
debug(templates)
foo("var", "whatever");
foo!("var", "whatever");
/* This will call dmd -run on this file. But instead of starting at main(),
* it starts by invoking foo() with the tuple ("var", "whatever").
* Mixed into the context will be the console output of the
* dmd -run call, in this case:
* char[8] var = "whatever";
*/
writefln(var);
}
Wouldn't this be very neat and powerful ?
Walter, about your concerns on malware autors:
Of course script interpretation within the compile-process could be used for malware. But also the malware could be put into the compiled code itself and get's started if the app is run. So I think it doesn't make any difference.
Best regards,
Daniel
More information about the Digitalmars-d
mailing list