Wednesday, January 20, 2010

Hello, World!

Well, after two and a half years of work, I finally managed to get "Hello World" working. This must be a record of some kind.

Basically it involved fixing a number of bugs in the compiler which had been vexing me greatly and preventing the "Hello World" example from compiling. One bug had to do with initialization of constant static objects that were referenced externally. Another involved union types as the return value of a function, which were being passed the data in the wrong format.

With these bugs out of the way, I can now write some fairly sophisticated code. For example, iterating over an array of tuples:

def testTupleIteration() { var s = [(1,2), (2,3), (3,4)]; var asum = 0; var bsum = 0; for a, b in s { asum += a; bsum += b; }
assertEq(6, asum); assertEq(9, bsum); }


Notice that there are no type declarations anywhere in this code - yet, the code is completely statically typed, which means that there are no runtime type checks involved. It also means that the number of machine instructions generated is relatively small, and it should run fast.

There are still a lot of items left on the TODO list. This includes things like garbage collection, platform configuration variables, generating stack dumps from exceptions, run-time annotations, const/volatile types, closure scopes, 'finally' blocks in try statements, string formatting, and much more.

No comments:

Post a Comment