<div dir="ltr">On 12 April 2013 14:46, Jesse Phillips <span dir="ltr"><<a href="mailto:Jessekphillips+d@gmail.com" target="_blank">Jessekphillips+d@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">It is that time, If you would like to see the proposed std.process include into Phobos please vote yes. If one condition must be met specify under what condition, otherwise vote no.<br>
</blockquote><div><br></div><div style>I didn't think I had much of an opinion on std.process, but I just gave it a quick once over and noticed, relating to our recent discussions about flagrant GC usage throughout phobos, that this is riddled with the exact sorts of issues I've been talking about:</div>
<div style><br></div><div style>string[string] is used in the main API to receive environment variables; perhaps kinda convenient, but it's impossible to supply environment variables with loads of allocations.</div><div style>
<br></div><div style>toStringz is used liberally; alternatively, alloca() could allocate the c-string's on the stack and zero terminate them there, passing a pointer to the stack string to the OS functions.</div><div style>
<br></div><div style>String concatenation is rampant! Look at this code to parse the env variables (which are already an AA):</div><div style><pre style="margin-top:0px;margin-bottom:0px;padding:0px;border:0px;font-size:12px;font-family:Consolas,'Liberation Mono',Courier,monospace;color:rgb(51,51,51);line-height:18px">
<div class="" id="LC566" style="margin:0px;padding:0px 0px 0px 10px;border:0px">    <span class="" style="margin:0px;padding:0px;border:0px;font-weight:bold">foreach</span> <span class="" style="margin:0px;padding:0px;border:0px">(</span><span class="" style="margin:0px;padding:0px;border:0px">var</span><span class="" style="margin:0px;padding:0px;border:0px">,</span> <span class="" style="margin:0px;padding:0px;border:0px">val</span><span class="" style="margin:0px;padding:0px;border:0px">;</span> <span class="" style="margin:0px;padding:0px;border:0px">childEnv</span><span class="" style="margin:0px;padding:0px;border:0px">)</span></div>
<div class="" id="LC567" style="margin:0px;padding:0px 0px 0px 10px;border:0px">        <span class="" style="margin:0px;padding:0px;border:0px">envz</span><span class="" style="margin:0px;padding:0px;border:0px">[</span><span class="" style="margin:0px;padding:0px;border:0px">pos</span><span class="" style="margin:0px;padding:0px;border:0px">++]</span> <span class="" style="margin:0px;padding:0px;border:0px">=</span> <span class="" style="margin:0px;padding:0px;border:0px">(</span><span class="" style="margin:0px;padding:0px;border:0px">var</span><span class="" style="margin:0px;padding:0px;border:0px">~</span><span class="" style="margin-top:0px;margin-bottom:0px;padding:0px;border:0px;color:rgb(221,17,68)">'='</span><span class="" style="margin:0px;padding:0px;border:0px">~</span><span class="" style="margin:0px;padding:0px;border:0px">val</span><span class="" style="margin:0px;padding:0px;border:0px">~</span><span class="" style="margin-top:0px;margin-bottom:0px;padding:0px;border:0px;color:rgb(221,17,68)">'\0'</span><span class="" style="margin:0px;padding:0px;border:0px">).</span><span class="" style="margin:0px;padding:0px;border:0px">ptr</span><span class="" style="margin:0px;padding:0px;border:0px">;</span></div>
</pre></div><div style><br></div><div style>And many many more of the same...</div><div style><br></div><div style>This is a lib that spawns a process, I can't imagine why this library should need to allocate a single byte, but it allocates wildly just to perform a trivial pass-through to the OS.</div>
<div style>This module is no exception either, basically all of phobos is like this, and I'd like to see careful consideration made to these details in the future.<br></div><div style><br></div><div style>I've said before, I sadly have to avoid phobos like the plague. Some modules (like this one) that provide fundamental functionality - not just helper functions - can't be avoided. Requirements for those should be extra strict in my opinion.</div>
</div></div></div>