{"id":49683,"date":"2025-10-17T15:36:25","date_gmt":"2025-10-17T19:36:25","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=49683"},"modified":"2025-10-17T15:36:25","modified_gmt":"2025-10-17T19:36:25","slug":"swift-proposal-module-selectors-for-name-disambiguation","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2025\/10\/17\/swift-proposal-module-selectors-for-name-disambiguation\/","title":{"rendered":"Swift Proposal: Module Selectors for Name Disambiguation"},"content":{"rendered":"<p><a href=\"https:\/\/github.com\/swiftlang\/swift-evolution\/blob\/main\/proposals\/0491-module-selectors.md\">SE-0491<\/a> (via <a href=\"https:\/\/queer.party\/@beccadax\/115199896810020566\">Becca Royal-Gordon<\/a>):<\/p>\n<blockquote cite=\"https:\/\/github.com\/swiftlang\/swift-evolution\/blob\/main\/proposals\/0491-module-selectors.md\"><p>We propose that Swift&rsquo;s grammar be extended so that, wherever an identifier\nis written in source code to reference a declaration, it can be prefixed by\n<code>ModuleName::<\/code> to disambiguate which module the declaration is expected to\ncome from. This syntax will provide a way to resolve several types of name\nambiguities and conflicts.<\/p><p>[&#8230;]<\/p><p>That may sound like a farfetched edge case, but it&rsquo;s surprisingly common for a\nmodule to contain a type with the same name. For instance, the <code>XCTest<\/code> module\nincludes an <code>XCTest<\/code> class, which is a base class for <code>XCTestCase<\/code> and\n<code>XCTestSuite<\/code>. To avoid this kind of trouble, developers must be careful to\ngive modules different names from the types inside them&mdash;the <code>Observation<\/code>\nmodule, for example, might have been called <code>Observable<\/code> if it didn&rsquo;t have a\ntype with that name.<\/p><p>[&#8230;]<\/p><p>We could allow a special token, or no token, to be used in place of the module name to force a lookup to start at the top level, but not restrict it to a specific module.<\/p><p>[&#8230;]<\/p><p>There is currently no way to add a module selector to a use of a subscript.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>SE-0491 (via Becca Royal-Gordon): We propose that Swift&rsquo;s grammar be extended so that, wherever an identifier is written in source code to reference a declaration, it can be prefixed by ModuleName:: to disambiguate which module the declaration is expected to come from. This syntax will provide a way to resolve several types of name ambiguities [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2025-10-17T19:36:28Z","apple_news_api_id":"efe002dd-9740-45f7-ba33-a30ea5645f29","apple_news_api_modified_at":"2025-10-17T19:36:28Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/A7-AC3ZdARfe6M6MOpWRfKQ","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[46,71,901],"class_list":["post-49683","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-languagedesign","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/49683","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=49683"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/49683\/revisions"}],"predecessor-version":[{"id":49684,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/49683\/revisions\/49684"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=49683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=49683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=49683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}