I am trying to use std.process.environment.get()
as described here: https://dlang.org/library/std/process/environment.get.html
I wrote this program to test it:
import std.stdio;
import std.process;
int main(string[] args)
{
string home = environment.get("HOME");
writeln("home is ", home);
return 0;
}
But it fails to compile:
$ ldc2 -of environment environment.d
environment.d(6): Error: template `object.get` cannot deduce function from argument types `!()(string)`
/usr/lib/ldc/x86_64-linux-gnu/include/d/object.d(3230): Candidates are: `get(K, V)(inout(V[K]) aa, K key, lazy inout(V) defaultValue)`
/usr/lib/ldc/x86_64-linux-gnu/include/d/object.d(3237): `get(K, V)(inout(V[K])* aa, K key, lazy inout(V) defaultValue)`
It works, though, to switch to a static import of std.process
:
import std.stdio;
static import std.process;
int main(string[] args)
{
string home = std.process.environment.get("HOME");
writeln("home is ", home);
return 0;
}
Why? What am I doing wrong in the first version that does not use the static import
?
My ldc2 version:
$ ldc2 -version
LDC - the LLVM D compiler (1.28.0):
based on DMD v2.098.0 and LLVM 11.1.0
built with LDC - the LLVM D compiler (1.28.0)
Default target: x86_64-pc-linux-gnu
Host CPU: skylake
http://dlang.org - http://wiki.dlang.org/LDC