To expand on this a bit, the syntax symmetry is also important for future extensions of the some
and any
syntax. Opaque types and existential types would both greatly benefit from being able to specify constraints on associated types. This could naturally be done in angle brackets, e.g. some Sequence<Int>
and any Sequence<Int>
, or the suggested alternative of some Sequence<.Element == Int>
(please don't bikeshed this here, if you're passionate about this feature, see [Pitch] Light-weight same-type constraint syntax ).
The Any<P>
alternative to any P
would necessitate either using nested angle brackets, e.g. Any<Sequence<Int>>
, or inventing two different syntax extensions to allow constraints on both opaque and existential types, e.g. Any<Sequence where .Element == Int>
vs some Sequence<.Element == Int>
.
Using the same syntax between these two different concepts also makes it really easy to replace any
with some
, and it is indeed the case that many uses of existential types today could be replaced with opaque types instead. This will be even more relevant if we extend some
to parameter position to enable implicit type parameters in generic signatures for functions.