Experimentation Stage

Erasure

Erasure is a process that removes type information or transforms types to more primitive types at compile time.

Lense does not uses parametric types (aka Generics) facilities from the underlying platform because they may not be compatible with Lense’s variance rules , or not even exist (think javascript). Thus all types are compiled as if they where not generic. However, Lense records all type information in metadata, for later use. This is similar to the strategy used for the java language.

Lense itself has reified generics, but at compile time some tricks happen so no parametric type information exists in the code. This is similar to the strategy used by java’s array where the type of the array is reified in the array object itself.

Primitive Erasure

The underlying Virtual Machine handles some types such as booleans and numbers more efficiently that a pure Object Oriented Lense Language can. Primitive erasure tries to gain this optimization by automatically change type signature from the Lense types to the primitive ones. This is only possible when values are not being used inside other values, so automatic boxing and unboxing are performed when necessary. Erasure allows for the compiled code to be more compatible with the platforms native code and thus more efficient, similar to the code you would write yourself by hand.

Where is the list of erased types so far.

Lense type

Erased to

lense.core.lang.Void

plataform’s primitive void

lense.core.lang.Boolean

plataform’s primitive boolean

Boolean constants (Boolean.False, Boolean.True) are also erased to their primitive counterparts (false, true).

lense.core.math.Int32

plataform’s primitive 32 bits integer

lense.core.math.Int64

plataform’s primitive 64 bits integer