Inefficiency with (Unbounded) Parameteric Polymorphism #117
Description
Terminology note: Parametric polymorphism is the use of instantiable type parameters, whereas subtype polymorphism is the use of subtyping.
In #114, the following extensions are described as part of a sketch for supporting parametric polymorphism (where I've removed bounds):
Allow type parameters on function types:
functype ::= (func <typeparam>* <valtype>* <valtype>*)
typeparam ::= (typeparam $x)
Add a way to reference a type parameter as a heap type:
heaptype ::= ... | (typeparam $x)
Generalise all call instructions (and
func.bind
) with a way to supply type arguments:
- e.g.,
call $f <heaptype>*
This extension makes subtyping at least quadratic time and no longer amortizable with memoization. The ability to instantiate type parameters with type arguments means new types are constructed during type checking and consequently have no entries in a memoization table.
This inefficiency in the presence of parametric polymorphism seems fundamental to the use of structural types in the current MVP.