Discussion on: What the heck is polymorphism?

jasontechnology profile image

Us grey beards call that a union :-)

jvanbruegge profile image
Jan van Brügge Author

Call what a union? I don't see any way a C union could be considered polymorphic. It is basically just a convenience for casting.

Or do you mean that a union is as far as you can bring C's type system?

madhadron profile image
Fred Ross

Not quite. It's implemented as a tagged union, but the power comes from building a full algebra that makes type composition trivial and very easy to reason about (thus the phrase "algebraic data type"). Their history goes back to the 1970's, so they're not much younger than C and they're older than object oriented programming.

occipita profile image

"Their history goes back to the 1970's, so they're [...] older than object oriented programming."

Errr... Object oriented programming dates back to Simula 67, released in 1967 (or even further -- you can do OOP without language support, as long as your language supports indirect function calls, and there are anecdotal stories of people creating objects in assembly language all the way back to the 50s).