Lerp Development Log:
Parameterized Type Instantiation
11 February 2006
Okay, it's been a while. I went in and introduced parameterized
type handling, so you can write code that looks like this:
struct Vector(Integer n) {
[(1..n) | ?Float];
}
struct Vector2 = Vector(2);
struct Vector3 = Vector(3);
struct Vector4 = Vector(4);
So first we define a Vector type, then we can define specializations of that
type. So if in code you later do this:
Vector2 v;
v[3] = 10;
The type will properly instantiate, and this assignment will be range-checked and generate an error. (Right now the checking only happens at runtime. When the language is in a reasonable state, I would explore doing a lot of this checking at compile time.) All this handling is a little bit kludgey right now -- I think defining parameterized types right now will only work when the base type is already defined in the global scope, etc. Those issues are relatively minor though and can be dealt with later.
Right now, types are not yet first-class entities in the language, so I can't yet do something like this:
struct Hash_String_To_Float = Hash_Table(String, Float);
That may be the next thing I work on.
[Back to Lerp Development Log]