Calling external programs from D
Lionello Lunesu
lio at lunesu.remove.com
Tue Apr 11 04:28:26 PDT 2006
Just some idea:
Wouldn't it be nice if there were an "extern (System)" calling
convention that would start external programs?
For example:
#extern (System) int wget(...);
#
#int main() {
# return wget("http://whatever");
#}
This would boost productivity especially for D scripts. Only too often I
need a small, temporary program to process some data and I wish I had
the compilable source of wget/grep/utility-x at hand to incorporate
their functionality.
Seems easy enough to implement using spawning/waiting. The program can
be declared with "..." or some defined arugments, but all arguments to
the function would have to be cast to char[] for passing to the new
process. Would of course be even cooler if the linker could pull in the
external program's main(), but I suppose that's a bit tricky :)
L.
More information about the Digitalmars-d
mailing list