JaiPrimer icon indicating copy to clipboard operation
JaiPrimer copied to clipboard

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

Open ngrilly opened this issue 8 years ago • 6 comments

ngrilly avatar Mar 18 '16 15:03 ngrilly

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).

refi64 avatar Mar 18 '16 17:03 refi64

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!

BSVino avatar Mar 18 '16 19:03 BSVino

Multiple inheritance?

refi64 avatar Mar 18 '16 20:03 refi64

Yep.

BSVino avatar Mar 19 '16 14:03 BSVino

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

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

ngrilly avatar Mar 20 '16 15:03 ngrilly

(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?

BSVino avatar Mar 20 '16 17:03 BSVino