<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>+1</div><div><br></div><div>-Thorsten</div><div><br>Am 29.12.2015 um 01:47 schrieb Kevin Ballard via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>>:<br><br></div><blockquote type="cite"><div>
<title></title>
<div>I like the idea here, but I'm not sold on the syntax. I also do explicitly want an `import qualified`. And with qualified imports, I question whether we really need to support renaming in the import syntax here.<br></div>
<div> </div>
<div>I'm tempted to say we should just crib Haskell's import rules (<a href="https://wiki.haskell.org/Import">https://wiki.haskell.org/Import</a>), with the minor change that importing members by name still makes them accessible via the module name too (in Haskell `import Mod (x, y)` makes `x` and `y` visible but does not make `Mod.x` or `Mod.y` visible). This lets you say things like<br></div>
<div> </div>
<div><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><b>import</b> Mod // imports Mod and all its members<br></span></div>
<div><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><b>import</b> Mod () // only provides access to protocol conformances declared in Mod, doesn't actually <b>import</b> anything</span><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><br></span></div>
<div><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><b>import</b> Mod <b>(</b>x,y<b>)</b> // imports `x` and `y`, which are also accessible as e.g. `Mod.x`, but does not provide `z` or `Mod.z`</span><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><br></span></div>
<div><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><b>import qualified</b> Mod // imports Mod but all access to members has to go through it, e.g. `Mod.x`</span><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><br></span></div>
<div><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><b>import qualified</b> Mod <b>(</b>x,y<b>)</b> // imports Mod but only provides access to `Mod.x` and `Mod.y` but not e.g. `Mod.z`</span><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><br></span></div>
<div><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><b>import </b>Mod <b>hiding</b> <b>(</b>x,y<b>)</b> // imports Mod and its members except for `x` or `y`<br></span></div>
<div><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><b>import qualified</b> Mod <b>hiding</b> <b>(</b>x,y<b>)</b> // imports e.g. `Mod.z` but not `Mod.x` or `Mod.y`</span><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><b><br></b></span></div>
<div><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><b>import</b> Mod <b>as</b> Foo // imports Mod and renames the module to Foo, so e.g. `x` and `Foo.x` are accessible<br></span></div>
<div><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><b>import</b> Mod <b>as</b> Foo <b>(</b>x,y<b>)</b> // renames Mod to Foo, provides `x`, `y`, `Foo.x`, and `Foo.y`</span><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><br></span></div>
<div><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><b>import qualified</b> Mod <b>as</b> Foo // renames Mod to Foo, all members are accessible via the module e.g. `Foo.x`</span><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><br></span></div>
<div><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><b>import qualified</b> Mod <b>as</b> Foo <b>(</b>x,y<b>)</b> // renames Mod to Foo, provides access to `Foo.x` and `Foo.y` but not e.g. `Foo.z`</span><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><br></span></div>
<div> </div>
<div>Furthermore, you can have multiple import statements from the same module, so you can say something like<br></div>
<div> </div>
<div><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><b>import qualified</b> Mod</span></div>
<div><span class="font" style="font-family: menlo, consolas, "courier new", monospace, sans-serif;"><b>import</b> Mod <b>(</b>x,y<b>)</b><br></span></div>
<div> </div>
<div>to provide access to all of Mod qualified with the name, and additionally import `x` and `y` as unqualified identifiers.<br></div>
<div> </div>
<div>-Kevin Ballard</div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=1MXK54sosN3xru3iYcLt0oBZ2w20i49gyogXctgrspcOS8bQSyHaq0lzwGLqVWMxOAkqP0PR9y8KuOAoM0gLfhs-2BHoc4BH5f49qN8o07E-2BzCglhVm6Ntb-2FVJa2af5BdKaiFxj7arY-2Bg9d-2FdleumuzNeWqbhryXz2p83TDVSVZtH-2B-2Fv-2BUwlzPMUrTuVY-2B68fZZpfmlGLHpxIp5YUTTm6rBixrZVuGH-2FJbJHt-2B-2F85mUGo-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;">
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>