The new std.process is ready for review
Lars T. Kyllingstad
public at kyllingen.net
Tue Mar 12 23:31:54 PDT 2013
On Wednesday, 13 March 2013 at 03:27:25 UTC, Vladimir Panteleev
wrote:
> On Tuesday, 12 March 2013 at 21:39:47 UTC, Steven Schveighoffer
> wrote:
>>> I'd be very interested to hear if you have a suggestion for a
>>> better way to do it, keeping in mind that there needs to be
>>> *some* way to clear the environment too.
>>
>> Sadly, no I don't. I had hoped [] would allocate an empty AA,
>> but it fails to compile.
>>
>> Note that you can "hack" it by setting a single environment
>> variable which nobody will ever use.
>>
>> i.e. spawnProcess("blah.exe", ["_____":"_____"]);
>>
>> But that is really, really ugly.
>
> How about this:
>
> @property string[string] emptyEnvironment()
> {
> string[string] result;
> result["a"] = "a";
> result.remove("a");
> assert(result && result.length == 0);
> return result;
> }
>
> (can be cached to avoid allocating each time)
That's a lot better than ["____":"_____"], at least. :)
But still, the difference between a null AA and an empty AA is
still very subtle, and I am hesitant to design an API that
depends on it. We'd have to explain to the users that "ok, so
there are two kinds of empty AAs: the ones you've done nothing
with, and the ones you've added and removed a value from..."
Furthermore, the language spec doesn't seem to mention "null" in
relation to AAs. Shouldn't the difference between null and empty
then be treated as an implementation detail? Can we even be sure
that "aa is null" will work in two years?
Lars
More information about the Digitalmars-d
mailing list