On Wednesday, 30 August 2017 at 17:57:49 UTC, data pulverizer
wrote:
The reason I have never really been comfortable with sub-typing
is that the polymorphic types are a black-box, my preference is
certainly for parametric type polymorphism. The main
disadvantage with parametric polymorphism in compiled languages
is that array containers only operate under subtyping
polymorphism. In the above Julia example the array container is
essentially acting exactly like a compile-time dispatch
(overloaded) function - the array is dispatching on a specific
set of types defined by the abstract parent type. That kind of
construct would be very desirable to me in D. The closest such
thing you can have to that in D are tuples.
I suspect the reason you can't have parametric typed array
containers in statically typed compiled languages is that
underneath, they are doubly/linked lists, and there is no way of
resolving the types at the end of the array, and allowing
appending at the same time ... someone correct me if I am wrong.