Monday, January 25, 2010

Well that was hard work, but was it worth it?

Not sure... I've replace the java implemented List with a DOS version, and it is immutable as well. It is pretty much a LISP list made of head and tail nodes. No need yet for much support, so only supplies those two values.

The difficult bit is that list is used to store both opcodes and arguments when constructing a new function/constructor. This means that these list changes had very far reaching effects. But it also means that a very important part of the system is now written in the system, rather than Java.

I have a feeling that more and more of the system will be converted in the coming (days? seems a bit optimistic). The more that's written in the VM opcodes, the smaller the VM will be, the better! Or at least that's the approach for this iteration. Once we have a feel for how small the VM is, we can start optimising some things (like replacing list with a native version...!).

Here is list (it has to be hacked a bit because we can't create new functions until list has actually been defined... so the comments are used to extract the functions to be manually created and applied to the emptyList object)


(constructor emptyList

// function start
(function prepend: object
newListWithHead: $object tail: $this
)
// function end

// function start
(function newListWithHead: head tail: tail
listConstructor: $head tail: $tail prototype: $this
)
// function end

// constructor start
(constructor listConstructor: head tail: tail prototype: listPrototype
parent: $listPrototype
)
// constructor end

// function start
(function head
$head
)
// function end

// function start
(function tail
$tail
)
// function end

// function start
(function at: index
$head // obviously wrong!
)
// function end
)

No comments:

Post a Comment