<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">This is something I’m dealing with as a framework author as well.<div class=""><br class=""></div><div class="">I’m stumped coming up with anything better than your latter idea of “outside” even though I’m not really a fan.</div><div class=""><br class=""></div><div class="">Either way, I think that deprecating outside makes some sense from a framework developer’s perspective. You may need to signal an API is “not to be relied on” despite knowing at least temporarily you will need to keep using it, but it’s not recommended for outside consumption for various reasons.. I also think there’s a lot of general work towards handling deprecation warnings cleanly in Swift that hasn’t been addressed, but that’s really for another topic.</div><div class=""><br class=""></div><div class="">- Rod</div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 10 Jul 2017, at 5:39 pm, rintaro ishizaki via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">2017-07-10 14:05 GMT+09:00 Xiaodi Wu <span dir="ltr" class="">&lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank" class="">xiaodi.wu@gmail.com</a>&gt;</span>:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This would be very useful, but the spelling needs dramatic improvement.<br class=""><br class="">"Available unavailable" is already challenging to read, but at least it is learnable with time. The example where "@available(*, deprecated, access: internal) open" means "fileprivate" is entirely unreasonable.<br class=""><br class=""></blockquote><div class=""><br class=""></div><div class="">I agree, but I couldn't come up with a better spelling.</div><div class=""><br class=""></div><div class=""><font face="monospace, monospace" class="">// "deprecated" if the access is from "outside" of "fileprivate" scope.</font></div><div class=""><font face="monospace, monospace" class="">@available(*, deprecated, outside: fileprivate)&nbsp;</font><span style="font-family:monospace,monospace" class="">open</span></div><div class=""><div class=""><br class=""></div></div><div class="">Hmm..&nbsp;🤔</div><div class=""><br class=""></div><div class="">Any suggestions will be greatly appreciated!</div><div class=""><br class=""></div><div class="">&nbsp;</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><div class=""><div class="gmail-m_465776830666725481m_5773591088566474201gmail-h5"><div dir="ltr" class="">On Sun, Jul 9, 2017 at 22:40 rintaro ishizaki via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></div></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class="gmail-m_465776830666725481m_5773591088566474201gmail-h5"><div dir="ltr" class="">Hi evolution community,<div class=""><br class=""></div><div class="">I would like to propose "Scoped @available" attribute.</div><div class=""><br class=""></div><div class="">What I want to achieve is to declare something that is publicly unavailable, but still usable from narrower scope. A concrete example is&nbsp;<font face="monospace, monospace" class="">IndexableBase</font>&nbsp;in the standard library:</div><div class=""><div class=""><a href="https://github.com/apple/swift/blob/master/stdlib/public/core/Collection.swift#L18-L20" target="_blank" class="">https://github.com/apple/swift<wbr class="">/blob/master/stdlib/public/cor<wbr class="">e/Collection.swift#L18-L20</a><br class=""></div><div class="">Workaround for this problem in stdlib is to use <font face="monospace, monospace" class="">typealias</font> to underscored declaration. However, we can't use this technique in our module because underscored declarations are still visible and usable from outside.</div><div class=""><br class=""></div></div><div class="">As a solution, I propose to add <font face="monospace, monospace" class="">"access"</font> parameter to <font face="monospace, monospace" class="">@available</font> attribute, which limits the effect of <font face="monospace, monospace" class="">@available</font>&nbsp;attribute to the specified&nbsp;value or outer.<br class=""><br class=""></div><div class="">---</div><div class=""><font face="monospace, monospace" class="">// Module: Library<br class=""><br class="">/// This protocol is available for internal, but deprecated for public.<br class="">@available(*, deprecated, access: public, message: "it will be&nbsp;</font><span style="font-family:monospace,monospace" class="">removed</span><font face="monospace, monospace" class="">&nbsp;in future")<br class="">public protocol OldProtocol {<br class="">&nbsp; &nbsp; /* ... */<br class="">}<br class=""><br class="">public Foo: OldProtocol { // No diagnostics<br class="">}</font></div><div class=""><font face="monospace, monospace" class=""><br class=""></font><div class="">---</div><font face="monospace, monospace" class="">// Module: main</font></div><div class=""><font face="monospace, monospace" class=""><br class="">import Library<br class=""><br class="">public Bar: OldProtocol { // warning: 'OldProtocol' is deprecated: it will be removed in future<br class="">}</font></div><div class=""><font face="monospace, monospace" class=""><br class=""></font></div><div class=""><div class="">---</div></div><div class=""><br class=""></div><div class="">I think this is useful when you want to stop exposing declarations, but want to keep using them internally.</div><div class=""><br class=""></div><div class="">More examples:</div><div class=""><br class=""></div><div class=""><font face="monospace, monospace" class="">// is `open`, going to be `filerprivate`</font></div><div class=""><font face="monospace, monospace" class="">@available(*, deprecated, access: internal)</font></div><div class=""><font face="monospace, monospace" class="">open class Foo {}</font></div><div class=""><font face="monospace, monospace" class=""><br class=""></font></div><div class=""><div class=""><font face="monospace, monospace" class="">// was `internal`, now `private`</font></div><div class=""><font face="monospace, monospace" class="">@available(*, unavailable, access: fileprivate)</font></div><div class=""><font face="monospace, monospace" class="">var value: Int</font></div><div class=""><font face="monospace, monospace" class=""><br class=""></font></div></div><div class=""><font face="monospace, monospace" class="">// No effect (invisible from public anyway): emit a warning</font></div><div class=""><div class=""><font face="monospace, monospace" class="">@available(*, unavailable, access: public)</font></div><div class=""><font face="monospace, monospace" class="">internal struct Foo {}</font></div></div><div class=""><br class=""></div><div class="">What do you think?</div></div></div></div>
______________________________<wbr class="">_________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailma<wbr class="">n/listinfo/swift-evolution</a><br class="">
</blockquote></div>
</blockquote></div><br class=""></div></div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>