mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 22:21:09 +03:00
39 lines
1.1 KiB
Text
39 lines
1.1 KiB
Text
`import std.experimental.all` as a global convenience import
|
|
|
|
$(MREF std,experimental,all) allows convenient use of all Phobos modules
|
|
with one import:
|
|
|
|
---
|
|
import std.experimental.all;
|
|
void main()
|
|
{
|
|
10.iota.map!log.sum.writeln;
|
|
}
|
|
---
|
|
|
|
For short scripts a lot of imports are often needed to get all the
|
|
modules from the standard library.
|
|
With this release it's possible to use `import std.experimental.all` for importing the entire
|
|
standard library at once. This can be used for fast prototyping or REPLs:
|
|
|
|
---
|
|
import std.experimental.all;
|
|
void main()
|
|
{
|
|
6.iota
|
|
.filter!(a => a % 2) // 0 2 4
|
|
.map!(a => a * 2) // 0 4 8
|
|
.tee!writeln
|
|
.sum
|
|
.reverseArgs!writefln("Sum: %d"); // 18
|
|
}
|
|
---
|
|
|
|
As before, symbol conflicts will only arise if a symbol with collisions is used.
|
|
In this case, $(LINK2 $(ROOT)spec/module.html#static_imports, static imports) or
|
|
$(LINK2 $(ROOT)spec/module.html#renamed_imports, renamed imports) can be used
|
|
to uniquely select a specific symbol.
|
|
|
|
The baseline cost for `import std.experimental.all`
|
|
is less than half a second (varying from system to system) and
|
|
work is in progress to reduce this overhead even further.
|