Skip to content

Commit 01e03a8

Browse files
committed
Add a global convenience package file
1 parent b905180 commit 01e03a8

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

changelog/import-std.dd

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
`import std` as a global convenience import
2+
3+
For short scripts a lot of imports are often needed to get all the
4+
modules from the standard library.
5+
With this release it's possible to use `import std` for importing the entire
6+
standard library at once. This can be used for fast prototyping or REPLs:
7+
8+
---
9+
import std;
10+
void main()
11+
{
12+
6.iota
13+
.filter!(a => a % 2) // 0 2 4
14+
.map!(a => a * 2) // 0 4 8
15+
.tee!writeln
16+
.sum
17+
.reverseArgs!writefln("Sum: %d"); // 18
18+
}
19+
---
20+
21+
As before, symbol conflicts will only arise if a symbol with collisions is used.
22+
In this case, $(LINK2 $(ROOT)spec/module.html#static_imports, static imports) or
23+
$(LINK2 $(ROOT)spec/module.html#renamed_imports, renamed imports) can be used
24+
to uniquely select a specific symbol.
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
`std.experimental.scripting` has been added
2+
3+
$(MREF std,experimental,scripting) allows to conveniently use all Phobos modules
4+
with one import:
5+
6+
---
7+
import std.experimental.scripting;
8+
void main()
9+
{
10+
10.iota.map!log.sum.writeln;
11+
}
12+
---
13+
14+
Importing entire Phobos costs about half a second (varying on the system) and
15+
work is in progress to reduce this overhead even further.

std/experimental/scripting.d

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/++
2+
Phobos is the D standard library, built on top of druntime.
3+
4+
Convenience file that allows to import entire Phobos in one command.
5+
+/
6+
module std.experimental.scripting;
7+
public import std.algorithm;
8+
public import std.array;
9+
public import std.ascii;
10+
public import std.base64;
11+
public import std.bigint;
12+
public import std.bitmanip;
13+
public import std.compiler;
14+
public import std.complex;
15+
public import std.concurrency;
16+
public import std.container;
17+
public import std.conv;
18+
public import std.csv;
19+
public import std.datetime;
20+
public import std.demangle;
21+
public import std.digest;
22+
public import std.encoding;
23+
public import std.exception;
24+
public import std.file;
25+
public import std.format;
26+
public import std.functional;
27+
public import std.getopt;
28+
public import std.json;
29+
public import std.math;
30+
public import std.mathspecial;
31+
public import std.meta;
32+
public import std.mmfile;
33+
public import std.net.curl;
34+
public import std.numeric;
35+
public import std.outbuffer;
36+
public import std.parallelism;
37+
public import std.path;
38+
public import std.process;
39+
public import std.random;
40+
public import std.range;
41+
public import std.regex;
42+
public import std.signals;
43+
public import std.socket;
44+
public import std.stdint;
45+
public import std.stdio;
46+
public import std.string;
47+
public import std.system;
48+
public import std.traits;
49+
public import std.typecons;
50+
//public import std.typetuple; // this module is undocumented and about to be deprecated
51+
public import std.uni;
52+
public import std.uri;
53+
public import std.utf;
54+
public import std.uuid;
55+
public import std.variant;
56+
public import std.xml;
57+
public import std.zip;
58+
public import std.zlib;

0 commit comments

Comments
 (0)