Beta 2.079.0

Martin Nowak code at dawg.eu
Fri Feb 23 11:57:05 UTC 2018


On Monday, 19 February 2018 at 15:58:57 UTC, Joakim wrote:
> 17. Allow multiple selective imports from different modules in 
> a single import statement

Let me hopefully conclude this discussion :).

We have an existing ambiguity in the language since at least dmd 
1.0. This is unfortunate but seems costly to remove and minor in 
impact (after learning this behavior).

     import trees, fruits : apple, birds;

A newcomer to D could rightfully conclude that comma is a module 
separator and the following is the correct syntax to import 
multiple symbols.

     import std.stdio, std.conv : to, std.conv : parse;

Embracing that existing ambiguity to support multi-module 
selective imports wasn't well received, partly because it 
amplifies the ambiguity and partly because multi-module imports 
are frowned upon.

On the plus side, we've understood that the actual wish for that 
syntax arised from scripting and example contexts, which might be 
better addressed by 
https://dlang.org/changelog/2.079.0.html#std-experimental-scripting, lazy import resolution by the compiler or a library, or automatic imports (https://github.com/CyberShadow/AutoFix).

Furthermore there remain various ideas that would avoid the 
original ambiguity. Whether such changes are worthwhile is up for 
discussion and would benefit from someone taking the lead.

I still think that local imports are nice for being explicit and 
toolable but have the downside of being brittle.
Something like bash style expansion could help to hit a sweet 
spot IMHO.

     import std.{algorithm : {find, findSplit}, stdio : writeln};
     import std.experimental.allocator.building_blocks.{free_list, 
region};

But certainly anything in that direction requires time and 
research, which I don't have for that topic.

In hindsight the voting experiment on 
https://github.com/dlang/dmd/pull/6589 might have prevented 
useful early feedback and thinking.

Given the effort required for a language change, it's seductive 
to streamline seemingly small changes, but it certainly increases 
the risk of design mistakes, thanks for appealing against this 
one.

-Martin


More information about the Digitalmars-d-announce mailing list