A new idea about generics

I don't like to have type parameters scattered all over the function. If we want to have named type parameter that can used anywhere, it's better to declare all of them at first, and shorthand should work only if there is no needs for name, so that they don't cause any additional complexity.

I disagree. What happens in this case? Why not T is used as type parameter of Queue? As the same reason for function type parameter, they should gathered in one place; otherwise it's hard to read (though easy to write).

struct Queue {
    func someFunction(_ value: <T>) {}
}

I cannot understand what changed here. In the generics manifesto, syntax similar to the former is treated as 'generic constant', it works the same as the latter. I think we should treat these two things as the same feature.

And though there is no type name, the similar feature to what you expected for the former can be already done.

let foo: some Numeric = 7

Therefore, it is a feature that reverse generics should treat. I think it should be like this.

let foo: <some T> = 7

I agree opening existential is a feature worth adding. But from the same reason, I don't think the syntax let value: <T: Equatable> = existential is apporopriate to do it.


This is referred in generics manifesto and previously discussed as parameterized extension here.

1 Like