Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Inefficiency with (Unbounded) Parameteric Polymorphism #117

Closed
@RossTate

Description

@RossTate

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions