<html><head></head><body>If I remember correctly it has been said that we don't need namespaces in favor of submodules, which schould solve these issues.<br> <br><div class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">-- <br>Adrian Zubarev<br>Sent with Airmail</div></div> <p class="gmail_quote" style="color:#000;">Am 30. Januar 2017 um 14:55:31, Tuur Anton via swift-evolution (<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>) schrieb:</p> <blockquote type="cite" class="gmail_quote"><span><div><div></div><div>
<title></title>
<div>The lack of namespaces is making people create all kinds of
"design patterns".<br></div>
<div><br></div>
<div>struct API {</div>
<div> static let endpoint = "<a href="http://example.com/api" target="_blank" rel="noopener noreferrer">http://example.com/api</a>"</div>
<div>}</div>
<div><br></div>
<div>Here is an "improvement" to the above "design pattern" to
prevent instantiating API:</div>
<div><br></div>
<div>struct API {</div>
<div> private init() {}</div>
<div> static let endpoint = "<a href="http://example.com/api" target="_blank" rel="noopener noreferrer">http://example.com/api</a>"</div>
<div>}</div>
<div><br></div>
<div>Finally, here is another "improvement" that uses enum instead
of struct to avoid having to write the private initializer:</div>
<div><br></div>
<div>enum API {</div>
<div> static let endpoint = "<a href="http://example.com/api" target="_blank" rel="noopener noreferrer">http://example.com/api</a>"</div>
<div>}</div>
<div><br></div>
<div>I doubt any of you find this beautiful. Yet these "design
patterns" (just hacks IMO) are spreading like the plague because of
the lack of namespaces.</div>
<div><br></div>
<div>What do you think?</div>
<div><br></div>
_______________________________________________<br>swift-evolution mailing list<br>swift-evolution@swift.org<br>https://lists.swift.org/mailman/listinfo/swift-evolution<br></div></div></span></blockquote></body></html>