public struct BinarySearchTree<Key: Comparable, Value> {
typealias Node = Node<Key, Value>
var root: Node?
}
private class Node<Key: Comparable, Value> { }
This code currently doesn’t compile because the Node typealias circularly
references itself. I’d like this syntax to just work, because this are the
alternatives:
- rename the typealias to something like `TheNode`
- rename the Node class
- don’t use a typealias at all
None of them are very favorable. Allowing this proposed syntax will (in my
opinion) lead to more readable code. In fact, inside the BinarySearchTree
struct, BinarySearchTree is already an implicit typealias of
BinarySearchTree<Key, Value>.
The only problem I foresee is that a generic typealias could cause confusion,
so perhaps that shouldn’t be allowed here._______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution