[erlang-questions] Maps

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Wed May 15 10:20:20 CEST 2013

On May 14, 2013, at 7:37 PM, Chris King <colanderman@REDACTED> wrote:

> Static structure does not preclude subtyping.  OCaml's functional
> objects capture this notion perfectly -- an object has a set of
> methods which are known at compile time (hence static).  However any
> given function need only be aware of the presence of the subset of
> methods in which it is interested.  Note that this does not preclude a
> function from creating a copy of said object with only those methods
> modified!

This is often called "structural subtyping" in contrast to "nominal subtyping". The difference is that the structural variant is implicit whereas the nominal variant is explicit. You have to explicitly define the relationsship in the nominal case, which is common in Java, C++, …

Google Go is another language with structural subtyping in its interface model. There is also some structurality in the Standard ML module system w.r.t. signature checks.

I agree we need something which is better than records at some point, with static guarantee of the contents. But currently, the thing we are missing is a fast map implementation which is functional, so we can avoid ETS tables for purposes they aren't designed for.

Jesper Louis Andersen
  Erlang Solutions Ltd., Copenhagen

More information about the erlang-questions mailing list