mixin D code into D code
Bill Baxter
dnewsgroup at billbaxter.com
Tue Feb 6 12:13:06 PST 2007
Daniel919 wrote:
> 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
Also, people download and run makefiles to build their software all the
time. Who knows what that makefile is doing. There could be an rm -rf /
buried in there somewhere in all that tab-sensitive gobbledy-gook.
--bb
More information about the Digitalmars-d
mailing list