BSVino / JaiPrimer

A description of Jonathan Blow's programming language, Jai
1.81k stars 81 forks source link

Section "Not planned" includes polymorphism, but Jai has polymorphic procedures and structs #8

Open ngrilly opened 8 years ago

refi64 commented 8 years ago

I think the "Not planned" section is referring to runtime polymorphism (e.g. C++ polymorphism), while Jai has parametric polymorphism (also known as generics or templates).

BSVino commented 8 years ago

When I wrote polymorphism there I meant class A : public B, public C ie a class that takes two supers. Not sure what the more specific term for that is, I haven't had time to go in and revise this thing lately. PR's would be appreciated!

refi64 commented 8 years ago

Multiple inheritance?

BSVino commented 8 years ago

Yep.

ngrilly commented 8 years ago

Ok, I think the proper term in this context is "subtype polymorphism":

https://en.wikipedia.org/wiki/Polymorphism_(computer_science)

BSVino commented 8 years ago

(Deleted a comment on the PR so the conversation is all in one place)

I think Jai actually has subtype polymorphism through using. May not be getting this syntax right, but:

A :: struct
{
}
B :: struct
{
    using a: A;
}
foo :: (a: A)
{
}

b: B;
foo(b); // Should work

When I wrote "polymorphism" in the document I specifically meant multiple inheritance polymorphism, but I think Jai actually has that too with multiple using statements.

Maybe it's best to just remove that line from the document?