Comments
Loading Dream Comments...
You must be logged in to write a comment - Log In
ArtistA beautiful purple-haired woman wearing a long purple velvet ankle-length dress with flouncy sleeves and purple suede high heels. She is ditting at a table eating corned beef hash.
We have already seen how we can define a class or struct :
MyClass <:: (a=1, b=2, squee="giggle");
This creates a two-dimensional array, whose first row is (1, 2, "giggle") and whose zeroeth row is ("a", "b", "squee") : its symbol table. This allows the symbols a, b, and squee to be used as variable names to name the fields of the struct (or members of the class) using the standard dot notation :
ttyout(MyClass.a, MyClass.b, MyClass.squee);
We can also use the array as a Hash Table :
String <:: "squee"; ttyout(MyClass[String]);
This looks up String in the symbol table (i.e. the array's zeroeth row) at runtime (the compiler did this at edit-time for field names, aka early binding), allowing a variable string to hash into our array, performing a table lookup.
We can also add extra fields (aka members) to our class/struct at runtime :
MyClass["foo"] <:: "bar"
Our class now contains the fields a, b, squee, and foo. We can even now say :
ttyout(MyClass.foo);
which prints "bar".
If a nonexistent field is selected (e.g. MyClass["woowoowoo"] or MyClass.woowoowoo), the value UNDEF or NULL is returned, denoted by ().