<div><br><div class="gmail_quote"><div dir="auto">On Mon, Oct 2, 2017 at 22:23 Slava Pestov <<a href="mailto:spestov@apple.com">spestov@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><blockquote type="cite"><div>On Oct 2, 2017, at 8:06 PM, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>> wrote:</div><br class="m_6381517663783222704Apple-interchange-newline"><div><div>On Mon, Oct 2, 2017 at 9:55 PM, Slava Pestov <span><<a href="mailto:spestov@apple.com" target="_blank">spestov@apple.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span><blockquote type="cite"><div>On Oct 2, 2017, at 7:52 PM, Kelvin Ma <<a href="mailto:kelvin13ma@gmail.com" target="_blank">kelvin13ma@gmail.com</a>> wrote:</div><br class="m_6381517663783222704m_9159439508092008430Apple-interchange-newline"><div><div>Is this only a problem with fileprivate or does it extend to private members too? I feel like this would be a very valuable feature to support.<br></div></div></blockquote><div><br></div></span>Private members too. Consider this example,</div><div><br></div><div>struct S {<br> private func f() {}<br>}</div><div><br></div><div>The member S.f mangles as _T06struct1SV1f33_AB643CAAAE0894CD0BC8584D7CA3AD23LLyyF. In this case, I suppose we won’t need the private discriminator because there can only be one S.f that’s directly a member of S, and not an extension. However imagine if two different source files both defined extensions of S, with a private member f. You would need to disambiguate them somehow.</div></div></blockquote><div><br></div><div>The simple-minded way to do this would be to require @_versioned annotations on private and fileprivate members to supply an internally unique alternative name to be used for mangling-as-though-internal (i.e. `@_versioned(my_extension_f)`). Such a function becoming public in an ABI-compatible way would require renaming the "actual" name to the unique @_versioned name.</div></div></div></div></div></blockquote><div><br></div></div></div><div style="word-wrap:break-word"><div>We have _silgen_name for that, but we really don’t want to expose this more generally because people have been abusing it to make things visible to C, and they should be using @_cdecl instead.</div></div></blockquote><div dir="auto"><br></div><div dir="auto">The difference here would be that the "@_versioned name" would be subject to mangling. It's essentially equivalent to a way of specifying a custom discriminator to be hashed so that the source file name is omitted and not ABI. Not that I think it'd be elegant, but it would not be abusable like _silgen_name.</div><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div></div></div><div style="word-wrap:break-word"><div><blockquote type="cite"><div><div><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>A more elegant refinement could be to have @_versioned private and fileprivate members mangled as though internal, erroring if two or more members with the same name are both @_versioned--would that work?</div></div><br></div></div>
</div></blockquote></div><br></div><div style="word-wrap:break-word"><div>If you’re going to do that what is the value in having the capability at all?</div></div></blockquote><div dir="auto"><br></div><div dir="auto">Solely to have some way of preventing members in one file from calling members in another file at compile time.</div><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div></div></div></blockquote></div></div>