is "import std;" a valid approach or a violation of the D programming language?

Witold Baryluk witold.baryluk at gmail.com
Sat May 15 13:59:15 UTC 2021


On Saturday, 15 May 2021 at 12:53:37 UTC, Patrick Schluter wrote:
> On Friday, 14 May 2021 at 22:33:24 UTC, Witold Baryluk wrote:
>> On Sunday, 9 May 2021 at 20:20:15 UTC, Berni44 wrote:
>>> [...]
>>
>>
>> Another disadvantage of using `import std` is compile time.
>>
>> I often have my projects on `sshfs` file system, that is 
>> mounted from a server in a different country. I often mount 
>> with default options, with has very short "negative cache" 
>> timeout (i.e. lookup was attempted, but didn't found a file), 
>> and medium "positive cache" timeout (lookup or read was done, 
>> and it did file and a content).
>>
>> [...]
>
> `import std;` has always been a convenience feature for D as 
> script language (`rdmd`). It was never intended to be part of a 
> normal project. Normal projects should use selective imports or 
> scoped imports. Using `import.std;` otherwise is a violation of 
> the intent.

I think `import std;` shouldn't be used for scripting. It just 
makes startup longer (which is important for scripts), and makes 
you vulnerable to future conflicts with new symbols in Phobos, 
which is a reality in anything other than most trivial scripts. 
Sure, it is a good start in rush to start with off, but nothing 
more.



More information about the Digitalmars-d mailing list