On Wednesday, 30 August 2017 at 17:29:42 UTC, Jean-Louis Leroy wrote:
On Wednesday, 30 August 2017 at 17:16:59 UTC, data pulverizer wrote:

p.p.s

typeof(x[1]) # returns Cat

so it isn't really polymorphism - the object is never converted to the "parent" type! Lol ... sorry for the confusion!

Haha what I know of Julia is what wikipedia says. Confusing indeed...

To be fair they say it is parametric polymorphism - dispatching basically template style, rather than subtyping polymorphism (OOP type), (more wikipedia https://en.wikipedia.org/wiki/Polymorphism_(computer_science)).

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.

Reply via email to