mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 14:10:30 +03:00
Add a global convenience package file
This commit is contained in:
parent
b905180b1f
commit
f8684bfb30
5 changed files with 123 additions and 3 deletions
39
changelog/std-experimental-scripting.dd
Normal file
39
changelog/std-experimental-scripting.dd
Normal file
|
@ -0,0 +1,39 @@
|
|||
`import std.experimental.scripting` as a global convenience import
|
||||
|
||||
$(MREF std,experimental,scripting) allows convenient use of all Phobos modules
|
||||
with one import:
|
||||
|
||||
---
|
||||
import std.experimental.scripting;
|
||||
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.scripting` for importing the entire
|
||||
standard library at once. This can be used for fast prototyping or REPLs:
|
||||
|
||||
---
|
||||
import std.experimental.scripting;
|
||||
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.scripting`
|
||||
is less than half a second (varying from system to system) and
|
||||
work is in progress to reduce this overhead even further.
|
|
@ -195,7 +195,7 @@ PACKAGE_std = array ascii base64 bigint bitmanip compiler complex concurrency \
|
|||
outbuffer parallelism path process random signals socket stdint \
|
||||
stdio string system traits typecons uni \
|
||||
uri utf uuid variant xml zip zlib
|
||||
PACKAGE_std_experimental = checkedint typecons
|
||||
PACKAGE_std_experimental = checkedint typecons scripting
|
||||
PACKAGE_std_algorithm = comparison iteration mutation package searching setops \
|
||||
sorting
|
||||
PACKAGE_std_container = array binaryheap dlist package rbtree slist util
|
||||
|
|
81
std/experimental/scripting.d
Normal file
81
std/experimental/scripting.d
Normal file
|
@ -0,0 +1,81 @@
|
|||
/++
|
||||
Convenience file that allows to import entire Phobos in one command.
|
||||
+/
|
||||
module std.experimental.scripting;
|
||||
|
||||
///
|
||||
@safe unittest
|
||||
{
|
||||
import std.experimental.scripting;
|
||||
|
||||
int len;
|
||||
auto r = 6.iota
|
||||
.filter!(a => a % 2) // 0 2 4
|
||||
.map!(a => a * 2) // 0 4 8
|
||||
.tee!(_ => len++)
|
||||
.sum
|
||||
.reverseArgs!format("Sum: %d");
|
||||
|
||||
assert(len == 3);
|
||||
assert(r == "Sum: 18");
|
||||
}
|
||||
|
||||
///
|
||||
@safe unittest
|
||||
{
|
||||
import std.experimental.scripting;
|
||||
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;
|
|
@ -284,7 +284,7 @@ SRC_STD_INTERNAL_WINDOWS= \
|
|||
std\internal\windows\advapi32.d
|
||||
|
||||
SRC_STD_EXP= \
|
||||
std\experimental\checkedint.d std\experimental\typecons.d
|
||||
std\experimental\checkedint.d std\experimental\typecons.d std\experimental\scripting.d
|
||||
|
||||
SRC_STD_EXP_ALLOC_BB= \
|
||||
std\experimental\allocator\building_blocks\affix_allocator.d \
|
||||
|
|
|
@ -309,7 +309,7 @@ SRC_STD_INTERNAL_WINDOWS= \
|
|||
std\internal\windows\advapi32.d
|
||||
|
||||
SRC_STD_EXP= \
|
||||
std\experimental\checkedint.d std\experimental\typecons.d
|
||||
std\experimental\checkedint.d std\experimental\typecons.d std\experimental\scripting.d
|
||||
|
||||
SRC_STD_EXP_ALLOC_BB= \
|
||||
std\experimental\allocator\building_blocks\affix_allocator.d \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue