On Wednesday, 30 August 2017 at 17:16:59 UTC, data pulverizer wrote:
On Wednesday, 30 August 2017 at 17:14:37 UTC, data pulverizer wrote:
On Wednesday, 30 August 2017 at 16:45:19 UTC, data pulverizer wrote:
You mentioned Julia in your article, however for clarity I would point out that Julia doesn't have OOP-type polymorphism. There is no notion of being able to do something like:

Animal snoopy = new Dog();

p.s. my bad, I was wrong about that! Turns out you can do something like this in Julia (apologies for the Julia code in a D forum):

abstract type Animal end
struct Dog <: Animal end
struct Cat <: Animal end

x = Array{Animal}(3)
x[1] = Cat(); x[2] = Dog(); x[3] = Cat();
x # returns
3-element Array{Animal,1}:
 Cat()
 Dog()
 Cat()

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!
Which is polymorphism

After mulling over this example, I don't see how this proves that Julia does *not* support run time polymorphism. On the contrary. If you translate this to D you get the same result by the way:

import std.stdio;

class Animal {}
class Cat : Animal {}

void main()
{
  Animal[] array;
  array ~= new Cat();
  writeln(typeid(array[0])); // typeid.Cat
}

Reply via email to