diff --git a/changelog/std-all.dd b/changelog/std-all.dd new file mode 100644 index 00000000000..366ecbf7f75 --- /dev/null +++ b/changelog/std-all.dd @@ -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. diff --git a/posix.mak b/posix.mak index 89e750d1c0b..5da6fcd23cd 100644 --- a/posix.mak +++ b/posix.mak @@ -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 diff --git a/std/experimental/all.d b/std/experimental/all.d index 7eee3792b47..a6648be9cc3 100644 --- a/std/experimental/all.d +++ b/std/experimental/all.d @@ -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; diff --git a/std/package.d b/std/package.d new file mode 100644 index 00000000000..8298837c465 --- /dev/null +++ b/std/package.d @@ -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; diff --git a/win32.mak b/win32.mak index 9509e2651fe..ee08d19257b 100644 --- a/win32.mak +++ b/win32.mak @@ -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) \ diff --git a/win64.mak b/win64.mak index 8105187db02..1b8aa6c6760 100644 --- a/win64.mak +++ b/win64.mak @@ -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) \