Skip to content

Move std.experimental.all to std #6889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions changelog/std-all.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
`std.experimental.all` has been moved to `std`

`std.experimental.all` allowed the convenient use of all Phobos modules
with one import (`import std.experimental.all;`). With this release, this
convenience module has been stabilized and moved to `std`. From now on, the
convenience module can be accessed with `import std;`:

---
import std;
void main()
{
5f.iota.map!exp2.sum; // 31
}
---

Scripts and experimental code often use long and frequently changing
lists of imports from the standard library.

With this release it is possible to use `import std;` for importing the entire
standard library at once. This can be used for fast prototyping or REPLs:

---
import std;
void main()
{
6.iota
.filter!(a => a % 2) // 1 3 5
.map!(a => a * 2) // 2 6 10
.tee!writeln // peek into the processed stream
.substitute(6, -6) // 2 -6 10
.mean // (2 - 6 + 10) / 3
.reverseArgs!writefln("Sum: %.2f"); // 2
}
---

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;`
is less than half a second (varying from system to system) and
work is in progress to reduce this overhead even further.
4 changes: 2 additions & 2 deletions posix.mak
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ STD_PACKAGES = std $(addprefix std/,\
PACKAGE_std = array ascii base64 bigint bitmanip compiler complex concurrency \
conv csv demangle encoding exception file format \
functional getopt json math mathspecial meta mmfile numeric \
outbuffer parallelism path process random signals socket stdint \
outbuffer package parallelism path process random signals socket stdint \
stdio string system traits typecons uni \
uri utf uuid variant xml zip zlib
PACKAGE_std_experimental = all checkedint typecons
PACKAGE_std_experimental = checkedint typecons
PACKAGE_std_algorithm = comparison iteration mutation package searching setops \
sorting
PACKAGE_std_container = array binaryheap dlist package rbtree slist util
Expand Down
83 changes: 4 additions & 79 deletions std/experimental/all.d
Original file line number Diff line number Diff line change
@@ -1,81 +1,6 @@
/++
Convenience file that allows to import entire Phobos in one command.
+/
// This module was kept for now to avoid breaking existing code
// @@@DEPRECATED_2.089@@@
deprecated("use `import std;` instead. This module will be removed with 2.089.")
module std.experimental.all;

///
@safe unittest
{
import std.experimental.all;

int len;
const r = 6.iota
.filter!(a => a % 2) // 1 3 5
.map!(a => a * 2) // 2 6 10
.tee!(_ => len++)
.sum
.reverseArgs!format("Sum: %d");

assert(len == 3);
assert(r == "Sum: 18");
}

///
@safe unittest
{
import std.experimental.all;
assert(10.iota.map!(partial!(pow, 2)).sum == 1023);
}

public import std.algorithm;
public import std.array;
public import std.ascii;
public import std.base64;
public import std.bigint;
public import std.bitmanip;
public import std.compiler;
public import std.complex;
public import std.concurrency;
public import std.container;
public import std.conv;
public import std.csv;
public import std.datetime;
public import std.demangle;
public import std.digest;
public import std.encoding;
public import std.exception;
public import std.file;
public import std.format;
public import std.functional;
public import std.getopt;
public import std.json;
public import std.math;
public import std.mathspecial;
public import std.meta;
public import std.mmfile;
public import std.net.curl;
public import std.numeric;
public import std.outbuffer;
public import std.parallelism;
public import std.path;
public import std.process;
public import std.random;
public import std.range;
public import std.regex;
public import std.signals;
public import std.socket;
public import std.stdint;
public import std.stdio;
public import std.string;
public import std.system;
public import std.traits;
public import std.typecons;
//public import std.typetuple; // this module is undocumented and about to be deprecated
public import std.uni;
public import std.uri;
public import std.utf;
public import std.uuid;
public import std.variant;
public import std.xml;
public import std.zip;
public import std.zlib;
public import std;
81 changes: 81 additions & 0 deletions std/package.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/++
Convenience file that allows to import entire Phobos in one import.
+/
module std;

///
@safe unittest
{
import std;

int len;
const r = 6.iota
.filter!(a => a % 2) // 1 3 5
.map!(a => a * 2) // 2 6 10
.tee!(_ => len++)
.substitute(6, -6) // 2 -6 10
.sum
.reverseArgs!format("Sum: %d");

assert(len == 3);
assert(r == "Sum: 6");
}

///
@safe unittest
{
import std;
assert(10.iota.map!(partial!(pow, 2)).sum == 1023);
}

public import
std.algorithm,
std.array,
std.ascii,
std.base64,
std.bigint,
std.bitmanip,
std.compiler,
std.complex,
std.concurrency,
std.container,
std.conv,
std.csv,
std.datetime,
std.demangle,
std.digest,
std.encoding,
std.exception,
std.file,
std.format,
std.functional,
std.getopt,
std.json,
std.math,
std.mathspecial,
std.meta,
std.mmfile,
std.net.curl,
std.net.isemail,
std.numeric,
std.parallelism,
std.path,
std.process,
std.random,
std.range,
std.regex,
std.signals,
std.socket,
std.stdint,
std.stdio,
std.string,
std.system,
std.traits,
std.typecons,
std.uni,
std.uri,
std.utf,
std.uuid,
std.variant,
std.zip,
std.zlib;
3 changes: 2 additions & 1 deletion win32.mak
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ SRC_STD_7= \
std\json.d \
std\parallelism.d \
std\mathspecial.d \
std\process.d
std\process.d \
std\package.d

SRC_STD= \
$(SRC_STD_1) \
Expand Down
3 changes: 2 additions & 1 deletion win64.mak
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ SRC_STD_7= \
std\json.d \
std\parallelism.d \
std\mathspecial.d \
std\process.d
std\process.d \
std\package.d

SRC_STD= \
$(SRC_STD_1) \
Expand Down