<div dir="ltr">again, i should reiterate, most users aren’t compiler engineers and so most people use access modifiers as a means of code organization. being able to diagnose when a “private” symbol is being referenced from somewhere it shouldn’t be is very important; the linking and mangling details should be handled by the compiler underneath all of that.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 2, 2017 at 11:45 PM, Slava Pestov <span dir="ltr">&lt;<a href="mailto:spestov@apple.com" target="_blank">spestov@apple.com</a>&gt;</span> wrote:<br><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 class=""><blockquote type="cite"><div>On Oct 2, 2017, at 9:15 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="m_-6769243278580835538Apple-interchange-newline"><div><div dir="auto" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br class="m_-6769243278580835538Apple-interchange-newline">On Mon, Oct 2, 2017 at 22:23 Slava Pestov &lt;<a href="mailto:spestov@apple.com" target="_blank">spestov@apple.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div><blockquote type="cite"><div>On Oct 2, 2017, at 8:06 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="m_-6769243278580835538m_6381517663783222704Apple-interchange-newline"><div><div>On Mon, Oct 2, 2017 at 9:55 PM, Slava Pestov<span class="m_-6769243278580835538Apple-converted-space"> </span><span>&lt;<a href="mailto:spestov@apple.com" target="_blank">spestov@apple.com</a>&gt;</span><span class="m_-6769243278580835538Apple-converted-space"> </span>wro<wbr>te:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);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 &lt;<a href="mailto:kelvin13ma@gmail.com" target="_blank">kelvin13ma@gmail.com</a>&gt; wrote:</div><br class="m_-6769243278580835538m_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_<wbr>AB643CAAAE0894CD0BC8584D7CA3AD<wbr>23LLyyF. 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)`)<wbr>. Such a function becoming public in an ABI-compatible way would require renaming the &quot;actual&quot; 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" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div dir="auto" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">The difference here would be that the &quot;@_versioned name&quot; would be subject to mangling. It&#39;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&#39;d be elegant, but it would not be abusable like _silgen_name.</div></div></blockquote><div><br></div></span>That wouldn’t solve the problem where removing @_versioned(name) and adding public would change the symbol’s name.</div><div><br></div><div>However, your idea of mangling versioned private symbols like internal and diagnosing conflicts might be workable.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Slava</div></font></span><span class=""><div><br><blockquote type="cite"><div><div dir="auto" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><blockquote class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);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" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div dir="auto" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Solely to have some way of preventing members in one file from calling members in another file at compile time.</div></div></blockquote></div><br></span></div></blockquote></div><br></div>