[swift-evolution] [Pitch] unavailable(*) attribute as alias for available(*, unavailable)
Dan Loewenherz
dan at lionheartsw.com
Wed Jul 20 09:22:06 CDT 2016
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
More information about the swift-evolution
mailing list