[Pitch] Rename `AnyObject` to `AnyClass` and drop current `AnyClass`

So what is the counterpart to AnyClass aka. AnyObject.Type for AnyValue? There is no and I don’t see any good name for it.

You could just use AnyValue.Type?
So basically you’re for consistency for `AnyValue` but not for current `AnyObject`.

It’s clear that `AnyValue` can represent more than one value type, where `AnyObject` can only represent one reference type (class). IMO for consistency it should be named as `AnyClass`.

More confusion with generalized existentials:

Any<class> vs. AnyClass aka AnyObject.Type
Any<class> makes it crystal clear that you’re using an instance of a class not an instance of .Type. It should be consistent.

Any<…> would be used for any of a certain type. So Any<class> to me says ‘any of class’, not ‘any class’. Whereas AnyClass says to me literally ‘any class’.
`Any<class>` and `AnyClass` should be the same otherwise it will lead to confusion!

If someone is new to the language and reads `AnyObject.Type` its not clear that a `.Type` instance of a class is meant, because its not clear what `Object` might be.

If then you also have existentials with any-class requirements and `AnyClass` typealias which is `AnyObject.Type` it would definitely lead to confusion between:

func foo(value: AnyClass & SomeProtocol) // this would be illegal with current implementation

vs.

func foo(value: Any<class> & SomeProtocol)

If one would want to use a `.Type` instance then should always type out `.Type` suffix after your type name: `AnyClass.Type` == any `.Type` instance of any class

I'm strongly against keeping `AnyClass` as an alias for `AnyObject.Type`, I’d consider to keep only `AnyObject` but if `Any<>` existentials were to come we’d get this mismatch:

typealias AnyObject = Any<class>

···

On 9 Jun 2016, at 9:23 PM, Adrian Zubarev via swift-evolution <swift-evolution@swift.org> wrote:

--
Adrian Zubarev
Sent with Airmail

So what is the counterpart to AnyClass aka. AnyObject.Type for AnyValue? There is no and I don’t see any good name for it.

You could just use AnyValue.Type?

So basically you’re for consistency for `AnyValue` but not for current `AnyObject`.

It’s clear that `AnyValue` can represent more than one value type, where `AnyObject` can only represent one reference type (class). IMO for consistency it should be named as `AnyClass`.

There could be one day more than one reference type, and AnyObject could also work with that.

More confusion with generalized existentials:

Any<class> vs. AnyClass aka AnyObject.Type
Any<class> makes it crystal clear that you’re using an instance of a class not an instance of .Type. It should be consistent.

Any<…> would be used for any of a certain type. So Any<class> to me says ‘any of class’, not ‘any class’. Whereas AnyClass says to me literally ‘any class’.

`Any<class>` and `AnyClass` should be the same otherwise it will lead to confusion!

If Any<class> was introduced, then I’d advocate for it being an outright replacement and just removing AnyObject.

···

On 9 Jun 2016, at 9:55 PM, Adrian Zubarev via swift-evolution <swift-evolution@swift.org> wrote:

On 9 Jun 2016, at 9:23 PM <http://airmail.calendar/2016-06-09%2021:23:00%20MESZ&gt;, Adrian Zubarev via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

If someone is new to the language and reads `AnyObject.Type` its not clear that a `.Type` instance of a class is meant, because its not clear what `Object` might be.

If then you also have existentials with any-class requirements and `AnyClass` typealias which is `AnyObject.Type` it would definitely lead to confusion between:

func foo(value: AnyClass & SomeProtocol) // this would be illegal with current implementation

vs.

func foo(value: Any<class> & SomeProtocol)

If one would want to use a `.Type` instance then should always type out `.Type` suffix after your type name: `AnyClass.Type` == any `.Type` instance of any class

I'm strongly against keeping `AnyClass` as an alias for `AnyObject.Type`, I’d consider to keep only `AnyObject` but if `Any<>` existentials were to come we’d get this mismatch:

typealias AnyObject = Any<class>

--
Adrian Zubarev
Sent with Airmail
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

There could be one day more than one reference type, and AnyObject could also work with that.
Classes are not the only reference types. Closures are reference types which we CANNOT extend with protocols.

···

--
Adrian Zubarev
Sent with Airmail

1 Like