On Mon, Jul 15, 2013 at 9:10 PM, Andrei Alexandrescu <span dir="ltr"><<a href="mailto:SeeWebsiteForEmail@erdani.org" target="_blank">SeeWebsiteForEmail@erdani.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 7/15/13 6:26 AM, Don wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Friday, 12 July 2013 at 20:42:50 UTC, Tofu Ninja wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
So I had an idea recently, wouldn't it be cool to have the ability to<br>
call an executable at compile time and capture its output. Something<br>
like the string imports but instead of opening and reading a text<br>
file, it run an executable, waits for it to finish, and grabs its output.<br>
<br>
It would get really cool if you could pass this executable some args<br>
and then mix in its out put into your own code. It could be used<br>
similarly to how CTFE are used but with out the overhead of trying to<br>
compile that function and what not and with out the limitations on<br>
what it can do.<br>
<br>
I could imagine all sorts of things that would be possible with this<br>
that is currently not.<br>
<br>
Not sure if this is something that could be implemented easily, but<br>
seems like something that could be done and something that would be<br>
really cool.<br>
</blockquote>
<br>
I personally think it's a *horrible* idea. It's one of those things<br>
which looks good in small cases but doesn't scale.<br>
</blockquote>
<br></div>
I think the right direction here is to factor compiler parts as a library. Then user code may insert external artifacts (notably REPL) on its own.<span class="HOEnZb"><font color="#888888"><br>
<br></font></span></blockquote><div> </div><div>CTFE exec would still be needed (see yet another use case in EMAIL:"Proof of concept: automatically import C header files"), but having a compiler-as-a-library would make implementation easier and more customizable, eg by redirecting certain symbols such as 'CTFE exec' to a given delegate.</div>
<div><br></div><div>myfile.d:</div><div>import std.process;</div><div>void main(){enum HOME=exec("echo $HOME", Redirect.all);} </div><div><br></div><div>driver.d:</div><div>import std.compiler;</div><div>void exec_dg(){...}</div>
<div>void main(){"myfile.d".readText.compile(&exec_dg);}</div><div><br></div><div><br></div></div>