[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Abominations of nature (was: Features you would like to see)
- From: David Given <dg@...>
- Date: Wed, 22 Aug 2007 12:54:04 +0100
-----BEGIN PGP SIGNED MESSAGE-----
David Kastrup wrote:
> As a note aside: there is an interesting native implementation of
> call/cc if I remember correctly: subroutines _never_ return. Instead,
> the call stack is garbage-collected&compacted together with the heap.
> That way, the dynamic context stays alive as long as it is needed.
Indeed. I've actually been thinking about that example I posted; there are a
lot of possibilities. By moving the dynamic chain off the stack and onto the
heap, a whole bunch of things become possible. Firstly, it's no longer a
chain, it can be a graph; as you say, a dynamic context. Secondly, non-local
gotos become trivial. Thirdly, coroutines become trivial. Fourthly, replace
the 'goto' with a little function that adds the new 'address' to a queue and
instead pops off the bottom item and jumps to that, and you get preemptive
multitasking. Fifthly, all this is happening *on the same lua_State*.
And it's all so simple it might even be *fast*... calling a function will be
fairly expensive, as it requires creating a lot of closures, but it should
still be easy meat for LuaJIT.
Once I'm done with my current project I might try and make a working example
out of this, and see how it goes... but before then, I have a lot of reading
âââ ïïïïïïïïïïïïïï âââ http://www.cowlark.com âââââââââââââââââââ
â "There does not now, nor will there ever, exist a programming language in
â which it is the least bit hard to write bad programs." --- Flon's Axiom
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----