Is “some” keyword really necessary?

Thank you for showing this case, but it's not the code I asked about. My question was about

protocol Dependency1 {}
protocol Dependency2 {}

func foo(_: any Dependency1, _: any Dependency2)
func foo(_: some Dependency1, _: some Dependency2)

There are no arrays. What is the difference between these two function signatures, except speed and more restrictions for the caller? What is the profit for foo of declaring some for its arguments?

In the simplest cases like these where the protocol does not have any static requirements and the types are not wrapped in other types, there is essentially no difference. However even then type(of:) is slightly different depending on whether you have a some or any.

Also remember that some in parameter position is just syntax sugar for a generic parameter having this constraint.


I already felt opposed to the idea of eliding some and then I had the experienced I described here which made me feel even more strongly that encouraging the conceptual conflation of protocols with concrete types would have a net-negative effect.


Got it, thanks