4 ms·
It does not matter what kinds of children they make... a collection has a well-typed-usage. When you get an item out of a collection, you have two options: (1)
by kazagistar 12y ago
It does not matter what kinds of children they make... a collection has a well-typed-usage. When you get an item out of a collection, you have two options:
(1) You inspect its type with reflection, and make a choice of what to do accordingly. This requires tagging the type at runtime, and is ugly no matter what.
(2) You will use the intersection of features provided by all the types. In other words, some interface representing what each object in the collection can do.
Either way is pretty straightforward to represent. In haskell, the first is a Dynamic type, and the second is a record containing the interface functions. I am pretty sure any other case is a runtime error, unless I missed something?