Was: Re: Vote for std.process

Manu turkeyman at gmail.com
Fri Apr 12 06:42:43 PDT 2013


On 12 April 2013 23:21, Lars T. Kyllingstad <public at kyllingen.net> wrote:

> On Friday, 12 April 2013 at 07:04:23 UTC, Manu wrote:
>
>>
>> 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.
>>
>
> Environment variables are a mapping of strings to strings.  The natural
> way to express such a mapping in D is with a string[string].  It shouldn't
> be necessary to allocate an AA literal, though.
>

That's a good point, do AA's support literals that don't allocate? You
can't even produce an array literal without it needlessly allocating.

 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.
>>
>
> It is kind of hard to use alloca() in a safe manner in D, because DMD will
> happily inline functions that use it.  The following program will overflow
> the stack if compiled with -inline:
>
> void doStuff()
> {
>     auto p = alloca(100);
> }
>
> void main()
> {
>     foreach (i; 0 .. 1_000_000) doStuff();
> }
>
> This is of course fixable, but until that happens, I would consider
> alloca() a no-go for Phobos.
>

Very good point. This is a problem.
Hmmm...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130412/1254bf29/attachment.html>


More information about the Digitalmars-d mailing list