<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Can you explain a little more about your motivation for this?<div class=""><br class=""></div><div class="">I understand that "SwiftString", as a package, may be something which is likely to conflict. It isn't however clear to me that most packages fall into that category, or that it is even desirable to support features that encourage it.</div><div class=""><br class=""></div><div class="">For packages like "libjpeg", "LLVM", "OpenGL", "ncurses", "zlib", it seems like having one global namespace is OK, and even useful. As a Python user, for example, I have never been bother that the Python package index is a global namespace.</div><div class=""><br class=""></div><div class="">Is part of your motivation that you expect a different usage of Packages in the Swift ecosystem? I can see how if the expectation is that there are a lot of micro-framework style packages for basic functionality (i.e., "CountedCollections" or "GraphAlgorithms") that maybe the usage patterns would lend themselves to more conflicts.</div><div class=""><br class=""></div><div class=""> - Daniel</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 26, 2016, at 9:30 AM, Erica Sadun via swift-build-dev <<a href="mailto:swift-build-dev@swift.org" class="">swift-build-dev@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class=""><div class=""><br class="Apple-interchange-newline">On Feb 19, 2016, at 5:50 PM, Max Howell <<a href="mailto:max.howell@apple.com" class="">max.howell@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Yes, we should probably take this to swift-build-dev.<br class=""><br class=""><blockquote type="cite" class="">I'd like to add a Package property to namespace packages by origin,<br class=""></blockquote><br class="">Some namespacing will certainly be required, the sooner the better.<br class="">I was hoping to namespace with github username where possible, it’s mxcl’s PromiseKit after all.<br class=""><br class=""><blockquote type="cite" class="">and to add aliases in Swift for renaming imports.<br class=""></blockquote><br class="">With namespacing we probably wouldn’t need this solution, which would be more ideal, eg:<br class=""><br class=""> import Foo<br class=""><br class="">Now you have two Foo, so any package that uses both must be specific:<br class=""><br class=""> import mxcl.Foo<br class=""> import erica.Foo<br class=""><br class="">Provided they are compiled such that the build system knows the namespaces at all times, we should be good. It’s only the user who doesn’t need to know at all times.</div></div></blockquote></div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Following up on this.</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; font-size: 1.1429em; line-height: 1.3125em; margin: 1.3125em 0px;"><em class="">I first brought this topic up on swift-dev, and was pointed to swift-build-dev.</em></p><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; font-size: 1.1429em; line-height: 1.3125em; margin: 1.3125em 0px;">Having spent considerable time messing up my Swift packages by giving them ridiculously obvious names like <code class="">SwiftString</code> and <code class="">SwiftCollections</code>, I realized that namespacing would be a solution for disambiguating conflicts. <code class="">import SwiftString</code> is insufficient when several packages are named <code class="">SwiftString</code>. </p><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; font-size: 1.1429em; line-height: 1.3125em; margin: 1.3125em 0px;">When you have two identically named packages, the module imports need to distinguish both the sources as well as references defined per package. Although SwiftPM finds packages using git URLs and module names, I do not believe that origin is addressable or usable. Plus, throughout the lifetime of a package, that origin could potentially move from, for example, GitHub to Bitbucket. </p><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; font-size: 1.1429em; line-height: 1.3125em; margin: 1.3125em 0px;">I suggest using some kind of origin key for differentiation. The simplest solutions for these include reverse domain names (basically a company/source identifier), git URLs (the current location of the repo), Github/Bitbucket user names (which are similar to a company/source identifier but more subject to updates over time). </p><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; font-size: 1.1429em; line-height: 1.3125em; margin: 1.3125em 0px;">Of these, I’d recommend reverse domain for the following reasons: </p><ul class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; font-size: 16px;"><li class="" style="font-size: 18px;">They are relatively short</li><li class="" style="font-size: 18px;">They are already well established for Apple app distribution</li><li class="" style="font-size: 18px;">They do not rely on a web address that may change should the repo move</li><li class="" style="font-size: 18px;">They are less likely to conflict with user names across repo hosts</li></ul><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; font-size: 1.1429em; line-height: 1.3125em; margin: 1.3125em 0px;">I’d imagine a package declaration that looks something like this:</p><pre class="" style="color: rgb(17, 17, 17); font-size: 16px;"><code class=" coffeescript hljs" style="display: block; padding: 0.5em; color: rgb(51, 51, 51); background-color: rgb(248, 248, 248);"><span class="hljs-reserved">import</span> PackageDescription
<span class="hljs-reserved">let</span> package = Package(
<span class="hljs-attribute" style="color: rgb(0, 128, 128);">name</span>: <span class="hljs-string" style="color: rgb(221, 17, 68);">"SwiftString"</span>
<span class="hljs-attribute" style="color: rgb(0, 128, 128);">origin</span>: <span class="hljs-string" style="color: rgb(221, 17, 68);">"org.sadun"</span>
)</code></pre><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; font-size: 1.1429em; line-height: 1.3125em; margin: 1.3125em 0px;">In the case of name conflicts instead of importing <code class="">SwiftString</code>, you’d prefix an origin:</p><pre class="" style="color: rgb(17, 17, 17); font-size: 16px;"><code class=" actionscript hljs" style="display: block; padding: 0.5em; color: rgb(51, 51, 51); background-color: rgb(248, 248, 248);"><span class="hljs-preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;"><span class="hljs-keyword" style="color: rgb(51, 51, 51);">import</span> org.sadun.SwiftString
<span class="hljs-keyword" style="color: rgb(51, 51, 51);">import</span> com.foobar.SwiftString</span></code></pre><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; font-size: 1.1429em; line-height: 1.3125em; margin: 1.3125em 0px;">Ideally, you could further alias these to shorten symbol disambiguation:</p><pre class="" style="color: rgb(17, 17, 17); font-size: 16px;"><code class=" vim hljs" style="display: block; padding: 0.5em; color: rgb(51, 51, 51); background-color: rgb(248, 248, 248);">import org.sadun.SwiftString <span class="hljs-keyword" style="font-weight: bold;">as</span> SadunStrings
import <span class="hljs-keyword" style="font-weight: bold;">com</span>.foobar.SwiftString <span class="hljs-keyword" style="font-weight: bold;">as</span> FoobarStrings
// Unique <span class="hljs-keyword" style="font-weight: bold;">to</span> <span class="hljs-keyword" style="font-weight: bold;">only</span> one package, <span class="hljs-keyword" style="font-weight: bold;">no</span> name conflict
uniqueMethod(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Hello World"</span>)
// name collision disambiguation
SadunStrings.sharedMethod(<span class="hljs-string" style="color: rgb(221, 17, 68);">"Hello World"</span>)</code></pre><div class="">I'm interested in hearing any feedback and thoughts about whether this is possible and what I could do to help further this idea.</div></div><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-build-dev mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-build-dev@swift.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">swift-build-dev@swift.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-build-dev" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-build-dev</a></div></blockquote></div><br class=""></div></body></html>