[swift-evolution] Discussion: Enforce usage of @available on enum cases

Jacob Bandes-Storch jtbandes at gmail.com
Wed May 25 22:18:54 CDT 2016


Was this an intentional choice, or is it just a temporary limitation? Would
a proposal to allow something like "@available(OS X 10.11)" be welcomed?


On Wed, May 25, 2016 at 8:17 PM, Jordan Rose via swift-evolution <
swift-evolution at swift.org> wrote:

> The “*” in @available means “all other platforms”. If you want to mark
> something *unavailable* on a particular platform, you’ll have to use the
> long form of the @available attribute. There’s currently no way to mark
> something “only available on these platforms”.
>
> Jordan
>
> On May 25, 2016, at 18:48, Stuart Breckenridge via swift-evolution <
> swift-evolution at swift.org> wrote:
>
> Presently, you can mark enum cases as @available but it has no impact.
> Take the following example:
>
> enum Things:String {
> @available (iOS 9.3, *) case MobileThing = "com.example.mobilething"
> @available (OSX 10.11, *) case DesktopThing = "com.example.desktopthing"
> }
>
> Despite the above compiling, the following code will run iOS with no
> warnings:
>
> func takesA(thing:Things) {
> print(thing)
> }
>
> takesA(.DesktopThing)
>
>
> Are there enough compelling use-cases for @available on enum cases to be
> considered? At the very least, if @available doesn't do anything on
> cases, it shouldn't be permitted.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160525/883d8bd2/attachment.html>


More information about the swift-evolution mailing list