On Friday, 23 February 2018 at 00:05:59 UTC, Martin Nowak wrote:
The main use-case for craming multiple imports into a line is
not libraries but scripting, examples, and maybe unit tests.
Those are cases when selective imports shouldn't be used.
experimental.scripting was introduced to reduce import length to
absolute minimum - 11 characters.
That's your opinion, my opinion is that importing 6 symbols
from 6 different modules for a tiny cli tool sucks and bloats
code example. So the alternative is to not use selective
imports, but only those and static imports have a clear path to
become lazy (https://issues.dlang.org/show_bug.cgi?id=13255).
Are renamed imports already lazy?
Tiny cli tool uses all its imports and doesn't benefit from
laziness, only libraries do.
- use std.experimental.scripting
Indeed an alternative with a similar goal, reducing the
amount of typing/noise for hacking. Importing all phobos
modules will lead to a couple of symbol conflicts (e.g. write),
It's perfectly thinkable to use both `write` functions, and
selective imports won't help you there, but renamed imports will.
Is it just me or people ignore existence of renamed imports?
and it still increases compile times and binary sizes noteably
(though compile time is a lot better than it used to be).
Is it because of dead templates? As a temporary solution you can
compile the code to a library, this way the linker will be able
to skip unreferenced code.
- why hasn't this been a DIP
Because it looked primarily like a minor grammar
rectification that doesn't break anything and is entirely
Also DIPs are a crucial process for our language, and it
seems problematic to clog it with trivialities.
Though the feature met skepticism from the start. Maybe voting
can be used as a simplified DIP process, just needs more people.
- it's useful for talks, posts, code puzzles or on a repl where
code is size constrained
Non-selective always win in terms of size.
- we're currently proliferating selective imports which cause a
lot of D code to become very brittle
I'd convert those to non-selective imports.
import std.algorithm.iteration, std.ascii, std.exception,
std.format, std.meta, std.range, std.stdio, std.string;
(well, my editor has decent word wrapping)