<< Previous | Next >>

Hotel at day ... 9, 10, 11 ...

Didn't have any time last weekend. And no internet at home this week (internet is back, so I'm putting this up now). Not good. But I did put in about 2 hours every evening, starting monday. I got calling functions working on monday, recursive scopes on tuesday, and some basic file input and parser enhancements wednesday. Result is that fibonacci works!

fun fib(x) {
    if (x < 2) return x
    return fib(x - 1) + fib(x - 2)
}
print(fib(8));

And it prints 21! Succes!

Not all is good though, because the if is fake; it always jumps a fixed amount in the bytecode (on false). I still have to make the parser calculate how much exactly, and jumpt over the else part if one is defined.

Also, if I put a print(x) anywhere inside the fib function, it will try and find the empty string as a symbol. I've spend some time debugging it, but I have no clue where it comes from. Well, not to worry, I do not have a single free in my c code right now, but am allocating plenty!

Next steps

Slowly I can work on the global scope and module scope. And some other small things.

If I have some larger amount of time I'll work on a somewhat more formalized runtime and memory model together with a serialized data format that will function as compiled bytecode and as serialized (or pickled, in python speak) data. The two will be closely related, so you can go from serialized to in memory representation and back quickly.

I'm hoping to accomplish that you can also serialize any closure or continuation, provided that the programmer doesn't capture the whole world in one of those. But more on that later.

Also next is to investigate how to implement a garbage collector, where the values should actually go, if strings are mutable and all that stuff ...

Last modified: 2007-11-19 20:18 GMT