twof
1
In the implemented proposal they say something to the effect of “type parameter pack stores a list of zero or more type parameters” in a few different places. What's the syntax to create a generic type or an instance of a generic type with zero type parameters? There was a followup proposal that was also implemented in 5.9 that includes this snippet
struct V<each T> {}
V<>.self
But this code doesn’t compile in 5.9. It complains that <> isn’t a valid operator.
twof
2
A few minutes after posting I found this bug report that had a solution. Referring to a type with an empty generic parameter pack causes "Cannot find operator '<>' in scope" error. · Issue #68290 · apple/swift · GitHub
You can get the above to compile by putting a space in between the two angle braces.
struct V<each T> {}
V< >.self
4 Likes
AlexanderM
(Alexander Momchilov)
3
Ah glad you found that.
It's definitely a better workaround than what I got 
struct V<each T> {}
func workaround<each T>(_: repeat each T) -> V<repeat each T>.Type {
return V<repeat each T>.self
}
print(workaround()) // => V<Pack{}>
1 Like
jrose
(Jordan Rose)
4
Might be backwards-incompatible to change. :-/ Someone could already have a postfix operator <>. Maybe in Swift 6 mode that can require parentheses?
2 Likes
twof
5
1 Like
bbrk24
6
postfix operator <> isn’t even a good defense, as currently it does not correctly select that interpretation in cases of ambiguity: SwiftFiddle - Swift Online Playground