From 57d023c290ebacd868ac4ea432a9d7686f5a7687 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Sat, 27 Jan 2018 03:21:46 +0100 Subject: [PATCH 1/3] Update spec for multiple selective imports --- spec/module.dd | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/spec/module.dd b/spec/module.dd index 1235818323..0325760f44 100644 --- a/spec/module.dd +++ b/spec/module.dd @@ -178,19 +178,15 @@ $(GNAME ImportDeclaration): $(GNAME ImportList): $(I Import) - $(I ImportBindings) $(I Import) $(D ,) $(I ImportList) $(GNAME Import): $(I ModuleFullyQualifiedName) $(I ModuleAliasIdentifier) $(D =) $(I ModuleFullyQualifiedName) + $(I ImportBindings) $(GNAME ImportBindings): - $(I Import) $(D :) $(I ImportBindList) - -$(GNAME ImportBindList): - $(I ImportBind) - $(I ImportBind) $(D ,) $(I ImportBindList) + $(I Import) $(D :) $(I ImportBind) $(GNAME ImportBind): $(I Identifier) @@ -407,6 +403,22 @@ void main() $(P $(D static) cannot be used with selective imports.) +$(P Selective imports can be imported from multiple modules if +those import are also selective or when the imported module has a qualified name:) + +$(SPEC_RUNNABLE_EXAMPLE_COMPILE +--- +import std.stdio : writeln, std.file : write, std.ascii; + +void main() +{ + writeln("hello!"); // ok, writeln from std.stdio + write("world.txt", "hello"); // ok, write from std.file + writeln(digits); // ok, digits from std.ascii +} +--- +) + $(H2 $(LNAME2 renamed_selective_imports, Renamed and Selective Imports)) $(P When renaming and selective importing are combined:) From be36f54110044bd30782daae6fa0dcdda15d4fcf Mon Sep 17 00:00:00 2001 From: Andrei Alexandrescu Date: Sat, 27 Jan 2018 21:34:42 -0500 Subject: [PATCH 2/3] Update module.dd --- spec/module.dd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/module.dd b/spec/module.dd index 0325760f44..a16297323a 100644 --- a/spec/module.dd +++ b/spec/module.dd @@ -403,8 +403,8 @@ void main() $(P $(D static) cannot be used with selective imports.) -$(P Selective imports can be imported from multiple modules if -those import are also selective or when the imported module has a qualified name:) +$(P Selective `import`s can be made from multiple modules if +all `import`s are selective, or when the imported module has a qualified name:) $(SPEC_RUNNABLE_EXAMPLE_COMPILE --- From cf44d16b564edaf96449a243c2a2df968f750a85 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Sun, 4 Feb 2018 00:36:26 +0100 Subject: [PATCH 3/3] Use an example with more than one import for a module --- spec/module.dd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/module.dd b/spec/module.dd index a16297323a..4f002fed23 100644 --- a/spec/module.dd +++ b/spec/module.dd @@ -408,11 +408,12 @@ all `import`s are selective, or when the imported module has a qualified name:) $(SPEC_RUNNABLE_EXAMPLE_COMPILE --- -import std.stdio : writeln, std.file : write, std.ascii; +import std.stdio : writeln, writefln, std.file : write, std.ascii; void main() { writeln("hello!"); // ok, writeln from std.stdio + writefln("%s!", "hello"); // ok, writefln from std.stdio write("world.txt", "hello"); // ok, write from std.file writeln(digits); // ok, digits from std.ascii }