On Wednesday, 6 March 2013 at 07:27:19 UTC, Lars T. Kyllingstad
wrote:
On Tuesday, 5 March 2013 at 21:04:15 UTC, Vladimir Panteleev
wrote:
5. How about that Environment.opIn_r?
Forgot about it. :) I'll add it.
So I sat down to write this function, but then I reconsidered.
The thing is, checking whether the variable exists is exactly the
same operation as retrieving it. In other words, this:
if (key in environment)
{
auto val = environment[key];
...
}
is equivalent to:
if (environment.get(key) !is null)
{
auto val = environment.get(key);
...
}
That just seems... wrong, somehow. Instead, I think we should
encourage code like this:
auto val = environment.get(key);
if (val !is null)
{
...
}
or, even better, IMO:
if (auto val = environment.get(key))
{
...
}
But feel free to convince me otherwise, you've had great success
with that so far. :)
Lars