[virtmach] bytecodes and stacks

Ceri Storey cez@nomorespam.freeserve.co.uk
Tue, 30 Nov 1999 20:45:16 +0000


on Fri, Nov 30, 1990 at 01:17:17PM +0800, Mark W. Humphries denied that:
}
}I think you'll find a 2 stack virtual machine model offers the best overall
}combination of flexibility and simplicity. One stack being used for
}function/subroutine parameter values, and one for subroutine return
}addresses (and optionally the exception chaining). This is the model
}advocated by most Forth programmers. Forth being the language that has
}traditionally had the simplest and lowest-level underlying virtual machine
}models.
}
personally, i can't see why why two stacks would be a better solution, 
since when the machine returns from a function, the arguments bound
in that procedure will be lost forever, and if a two stack model were
used, the virtual machine/ programmer would need to pop the excess data
from the data stack. also, i intend to have a calling convention
somewhat like continuations in scheme, where instead of doing a 'ret',
you apply the continuation, with the return value as an argument,
hence the continuation will be just another piece of data. The garbage
collection may get a little hairy, (the closed-over variables etc) but
then again I'll just write it on top of guile, and use their gc. :)

-- 
-----------| Ceri Storey
   _\|/_   | http://cez.freeshell.org/
  o(O O)o  |    {for geek code also}
_o0O(_)O0o_| cez@nomorespam.freeserve.co.uk