<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 30, 2017, at 5:55 AM, Tuur Anton via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta http-equiv="content-type" content="text/html; charset=UTF-8" class="">
<div class="">
<div class="">The lack of namespaces is making people create all kinds of "design patterns".<br class=""></div><div class=""><br class=""></div><div class="">struct API {</div><div class=""> static let endpoint = "<a href="http://example.com/api" target="_blank" rel="noopener noreferrer" class="">http://example.com/api</a>"</div><div class="">}</div><div class=""><br class=""></div><div class="">Here is an "improvement" to the above "design pattern" to prevent instantiating API:</div><div class=""><br class=""></div><div class="">struct API {</div><div class=""> private init() {}</div><div class=""> static let endpoint = "<a href="http://example.com/api" target="_blank" rel="noopener noreferrer" class="">http://example.com/api</a>"</div><div class="">}</div><div class=""><br class=""></div><div class="">Finally, here is another "improvement" that uses enum instead of struct to avoid having to write the private initializer:</div><div class=""><br class=""></div><div class="">enum API {</div><div class=""> static let endpoint = "<a href="http://example.com/api" target="_blank" rel="noopener noreferrer" class="">http://example.com/api</a>"</div><div class="">}</div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">What do you think?</div> </div></div></blockquote><br class=""></div><div>Personally, I’m in favor of namespaces, but it’s more of a “seems like a good idea” thing than “I need this because <reason>”, at least from my PoV. I’m inclined to just defer to the core team’s judgement on this one.</div><div><br class=""></div><div>On the plus side though, if we ever do get formal namespaces, it should be relatively simple to search for enums with no cases and give a fixit.</div><div><br class=""></div><div>- Dave Sweeris</div><br class=""></body></html>