Questions tagged [polymorphism]

For questions about polymorphism, when functions, methods, types, classes, or objects may be used with or as multiple types. Use when more specific tags like parametric-polymorphism or subtyping are not suitable or do not cover all polymorphism in the question.

Filter by
Sorted by
Tagged with
30 votes
2 answers
8k views

How expressive of a type system is too expressive, for the average programmer?

The advantages of an expressive type system cannot be denied. The usual definition applies - how much valid behaviour a chosen system allows, while also preventing invalid behaviour. In terms of "...
blueberry's user avatar
  • 2,315
2 votes
1 answer
151 views

Virtual functions from two classes

Years ago, I have implemented something in C++ that involves two kinds of list of the same value type: a sparse list and a dense list. Each operation between two lists has 4 versions (two of them are ...
user23013's user avatar
  • 2,220
15 votes
1 answer
187 views

Pros and cons of overloading vs type classes or similar polymorphism

I'm playing with creating a language after doing the LLVM Kaleidoscope tutorial. I've added some basic type checking, and now I want to add some functions that write things to standard output, as must ...
Rob N's user avatar
  • 1,073
15 votes
4 answers
383 views

How can polymorphism in a structural type system be compiled?

In a structural type system, a type can be assignable to another type without this relationship necessarily being declared. For example, in Typescript ...
kaya3's user avatar
  • 17.2k
10 votes
1 answer
104 views

Static or dynamic dispatch for parametric polymorphism

I read that, in GHC: Type classes are implemented using a type-directed implicit parameter-passing mechanism. Each constraint on a type is treated as a parameter containing a dictionary of the ...
pxeger's user avatar
  • 838