lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Enrico Colombini wrote:
[...]
> It depends on your definition of "newcomers" :-)
> They were definitely not new in 1979 (Motorola's 6809 supported them)
> but keeping stuff in the stack was not uncommon even with the 6502, even
> without direct hardware support.

I've tried making C compilers work on the 6502 and Z80; while they do
have stacks, they only really like doing pushes and pops and are
egregiously unoptimised for stack frame random access. Trying to do
Algol-like languages is essentially an exercise in frustration. OTOH
they do languages like Forth really well. One day I must hunt down a
non-stack-frame block-oriented language that's suitable for this class
of processor.

There's also a class of languages that is stack frame oriented but which
doesn't use stacks. Each function call essentially allocates a new frame
on the heap. This makes coroutine creation essentially no more expensive
than a normal function call, and also allows some really freaky stuff
like continuations --- calling a function which records its current
stack frame before returning, then jumping back to that stack frame
later, causing the function to return again!

I know Lisp has these, but my Lisp-fu is very weak. I don't know of any
other languages (Smalltalk has sanitised continuations in that you can
return from a method from a block defined inside that method, but only
while the method is actually active, IIRC). I do know that you need
really high-tech garbage collectors to make them at all efficient (which
of course Lisp did).

- --
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│ "There is nothing in the world so dangerous --- and I mean *nothing*
│ --- as a children's story that happens to be true." --- Master Li Kao,
│ _The Bridge of Birds_
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFK/J5uf9E0noFvlzgRAgcuAJ4pUjktM0KoMMJCdzlnvXvyMLSomACeNAP8
zwCjor+OuUEeBmM4S3WBcBU=
=4krS
-----END PGP SIGNATURE-----