[Pitch] unavailable(*) attribute as alias for available(*, unavailable)

I find myself using the @available(*, unavailable) pattern quite
often, and the more I use it, the more weird it feels to use a name
called “available” to mark something as "unavailable". I propose
creating a new attribute, called @unavailable, that takes an
availability argument, an optional message, and an optional renamed
value, that does the same thing as adding “unavailable” to the
@available attribute.

Usage:

// Make the method unavailable on all platforms
@unavailable(*) == @available(*, unavailable)
func hi() {
    print(“Hi.”)
}

// Make the method unavailable on watchOS, refer to its renamed counterpart
@unavailable(*, renamed="hello") == @available(*, renamed="hello", unavailable)

// Make the method unavailable on watchOS, refer to its renamed
counterpart, and add a message
@unavailable(*, renamed="hello", message="This method had been
renamed") == @available(*, renamed="hello", message="This method had
been renamed", unavailable)

** I’m not subscribed to the ML so please include me in replies. :)

Best,
Dan

Oops, some typos in my original message. Fixes below:

// Make the method unavailable on watchOS, refer to its renamed counterpart
@unavailable(*, renamed=“hello") == @available(*, renamed="hello", unavailable)

Should be:

@unavailable(watchOS, renamed=“hello”)

// Make the method unavailable on watchOS, refer to its renamed
counterpart, and add a message
@unavailable(*, renamed="hello", message="This method had been

renamed”)

Should be:

@unavailable(watchOS, renamed=“hello”, message=“This method had been renamed")

Dan

···

On Wed, Jul 20, 2016 at 9:22 AM, Dan Loewenherz <dan@lionheartsw.com> wrote: