On Tue, 12 Mar 2013 05:13:59 -0400, Vladimir Panteleev <[email protected]> wrote:

On Tuesday, 12 March 2013 at 08:58:13 UTC, Lars T. Kyllingstad wrote:
For AAs, 'in' returns a pointer to the element, which is null if the element does not exist. I can't think of a good way to implement this. Since we have to convert the raw environment variable to a D string anyways, we'd have to do something like:

  string* opIn_r(string var)
  {
      auto val = get(var);
      if (val is null) return null;
      else return [val].ptr;
  }

but that seems rather pointless to me.

Yes. That use of the "is" operator is mainly to allow updating the value

you meant "in", not "is", right?

without looking up the key twice. This behavior could be implemented using a proxy object, but this is not what I was talking about. I meant the specific case of "if (key in environment)".

I think Valdimir wants to have opIn_r return bool?

-Steve

Reply via email to