is "import std;" a valid approach or a violation of the D programming language?
Dennis
dkorpel at gmail.com
Thu May 6 22:36:05 UTC 2021
On Thursday, 6 May 2021 at 22:27:21 UTC, Steef Boerrigter wrote:
> My question is now, am I abusing an oversight in dmd when I
> import the entire phobos library, or is it a bug of gdc to
> *not* accept this approach?
The `std` package is a relatively recent addition (DMD 2.086),
and gdc is simply a bit behind on the latest front-end currently.
It used to be called `std.experimental.all`, so you could do:
```D
static if (__VERSION__ <= 2085) {
import std.experimental.all;
} else {
import std;
}
```
Note that it is discouraged to use outside scripts / small
applications, because every time a new symbol is added into
Phobos, there is potential it could clash with one of your own
symbols. For example, say you already imported your own
`SumType`, and then `std.sumtype` was added. You now get
ambiguous symbol errors because you're importing `std.sumtype`
unintentionally.
More information about the Digitalmars-d
mailing list