[swift-evolution] [Pitch] Rename `AnyObject` to `AnyClass` and drop current `AnyClass`

Adrian Zubarev adrian.zubarev at devandartist.com
Fri May 20 06:52:04 CDT 2016

I’d like to discuss with the community to see their reactions on that topic.

Basically from the beginning of Swift I thought it was just confusing how these typealiases were used and named.
As we know from Apply API Guidelines to the Standard Library the Type suffix will be dropped.

Currently we also discuss about the `Any<…>` existential which may contain Any-type requirement one day (by ’type’ I mean `class`, `struct`, `enum` in a way like this: `Any<class>`).

The Any-class requirement could replace the current `AnyObject` protocol with a typealias like this: `typealias AnyObject = Any<class>`

Assume Swift would introduce Any-struct and Any-enum requirement one day. How would one name a typealias for these, where `AnyClass` means `AnyObject.Type`?

I suggest we drop the current `AnyClass` and rename `AnyObject` to `AnyClass`. If one would need the old `AnyClass` behavior it will become `AnyClass.Type`.

In the future we could have typealiases like this, which are more clear:

`typealias AnyClass = Any<class>`
`typealias AnyStruct = Any<struct>`
`typealias AnyEnum = Any<enum>`

I don’t know how the migration process works but I can assume that this should be done in the right order:

- migrate every `AnyClass` to `AnyClass.Type`
- at the end migrate `AnyObject` to `AnyClass`

What do you think? I’d write a small proposal if the community reaction is positive. 

Adrian Zubarev
Sent with Airmail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160520/4849afef/attachment.html>

More information about the swift-evolution mailing list