Rename `Any` to `Value` and `AnyObject` to `Object`?

From SE-0335:

Instead of leaving Any and AnyObject in their existing spelling, an alternative is to spell these types as any Value and any Object , respectively. Though this is more consistent with the rest of the proposal, this change would have an even bigger source compatibility impact. Given that Any and AnyObject aren’t as harmful as other existential types, changing the spelling isn’t worth the churn.

I understand a source break is not worth it, but I think it's too bad we cannot have the consistency. Personally, I'm completely ok with some churn in my own codebase to improve consistency.

Could Value and Object be added and AnyObject/Any simply be made a typealias of these? There would be no need to emit a warning or anything. Just let devs use something more consistent in new code.

11 Likes

I'm strongly in favor or going the extra mile to keep the syntax consistent!

The only problem that I can see is in the name Value:

  • The name Value, if used to represent an arbitrary value would at best close the door on an intuitive name for a protocol to which all value types conform to, and at worst would cause confusion comparing to such a protocol.
  • The name Value is an extremely frequent associated type name. The migrator would have to conservatively replace Any with any Swift.Value, which would leave a huge number of those replacements needlessly verbose.
1 Like

The bar for a source-breaking change is that the current state of affairs is causing active harm. I'm really not aware of any such harm. Moreover, the proposed change would need to solve whatever harm it is that's identified. Yet an issue with Value specifically is that it suggests value semantics (see previous discussions about AnyValue), which would not be apt for Any and liable to cause actual user confusion. Note also that this alternative has been reviewed in SE-0335, and the approved stance is that "changing the spelling isn't worth the churn"—so unless I'm mistaken this is a settled topic not subject to further debate.

6 Likes