Skip to content
dherman edited this page May 19, 2011 · 6 revisions

First-class, mutable, interior slots

The runtime representation of a `slot.` is bit-for-bit identical to the runtime representation of a `T`. This means that a parametric container can be given mutable and immutable variants by instantiating with an immutable element type `T` and a mutable element type `slot.`.

Providing first-class support for mutable, interior slots makes it possible to create mutable vectors without having to have two different kinds of vectors. This allows us to write a simple, polymorphic map:

fn map.<T,U>(f : &fn(T) -> U, v : T[]) : U[] {
    ...
}

There is one single implementation, and the immutable version will produce an immutable vector, and the mutable version will produce a mutable version.

Collapsing nested slots

Type checking

Code generation

Clone this wiki locally