mixin D code into D code

John Reimer terminal.node at gmail.com
Tue Feb 6 16:06:44 PST 2007


On Wed, 07 Feb 2007 05:13:06 +0900, Bill Baxter wrote:

> 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


Very good point.

Any auxillary tool in the compilation process could could do the same.  I
have difficult recognizing the validity of Walter's concern in this context.

-JJR



More information about the Digitalmars-d mailing list