Hey there everyone, I've decided to roll my own scripting language from scratch. At present my VM executes fast and fine until it reaches a blocking call at which time the whole works will freeze until it's unlocked (for instance a long iterative loop). One solution I've come up with is to spawn a child VM, pass the child a reference to the parent, pass it a copy of the stack sections it's going to need, run the child in it's own thread, and have the child notify the parent when the process completes.
This works ok, but there is a whole lot of overhead and extra code involved. I've been reading a lot about language design and one thing that intrigues me is a stackless model. It appears to be some sort of programming cure-all but I don't really understand what a stackless language involves, or how it is different from my stack model. The only way I can see to implement a "stackless" language would be to create some sort of "state" object that is handed from function to function as a reference and then when it's state is "marked complete" it calls back the VM or controller object. This would essentially just be a stack thats passed around, which of course means it's not really stackless, it's more or less a multi stack implementation, with the advantage of not causing a blockage. Also I can see it allowing a "simulated thread" or co-routines, without the overhead involved in a full context switch. However there is the potential for a whole lot of overhead in the creation and destruction of such an object. There are possibly other problems as well, but thats the only one I can think of right now. Anyways for anyone versed in language design, compiler theory etc. What am I missing here? How exactly does a stackless language work? What are the pitfalls of a stackless language? Thanks in advance! Regards, /* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */
