Robbert, > is it possible to have strongly typed avail programs (at compile time), > *without* carrying to much types around (at runtime). > in short: type erasure. > the thing is, i don’t like to pay the (memory) overhead of types at runtime, > unless i (optionally) want so.
An Avail value does not carry its type around at runtime, so there is no need to erase anything. Instead, any Avail avail is able to compute its type on demand. This type is always exactly precise — it is the instance type of the value itself, i.e., a type whose sole instance is the interrogated value. An instance type is computed in constant time and requires constant space. The cost only enters when you attempt to establish the relation of this type to other types. The most frequent (invisible) occurrence of this is during method dispatch, but it is extremely cheap unless the call site is megamorphic. The other major place where this occurs (invisibly) is during method return, when a value is compared against the expected return type computed by a semantic restriction; the expense of this depends upon the complexity of the complexity of the type computed by the semantic restriction. Otherwise, type comparisons happen when your code explicitly performs runtime type operations. So our implementation should generally give you the best of all possible worlds — though there are probably ways to make semantic restriction type-checking much faster and more infrequent… Todd L Smith CEO | The Avail Foundation, LLC http://www.availlang.org
