[virtmach] lambda

David Rush kumo@bellsouth.net
09 Dec 1999 10:41:34 +0000


"Stephen Pelc" <sfp@mpeltd.demon.co.uk> writes:
> David Rush wrote:
> > Ceri Storey <cez@nomorespam.freeserve.co.uk> writes:
> > > in a bytecode based VM, is it possible to have a lambda opcode? (as in
> > > scheme/lisp/lambda calculus) woud it be a case of pushing a pre
> > > comipled function onto the stack (from a vector of constants, as in
> > > emacs) or can you create one from the nomal 'stream' of instructions?
> > Others may disagree, but I don't think so. At least not in the way
> > that you have phrased the question (Although Forth machines in
> > particular probably *can*, compiler interaction is strange and
> > wonderful in their world).
> This isn't my field at all, but given the comment that Forth 
> machines probably can, I don't understand why Forth machines 
> rather than others should be capable of this.

Well it isn't mine anymore, really. Its been over ten years since I
hacked anything resembling a threaded language, hence my use of
'probably.' My recollections of the Forth world are that, while it is
still turing-complete, it presents a fairly unique model of
computation, where the compiler/interpreter boundary is rather fuzzier
than usual.

> > The problem is that identifying a string of
> > instructions as a well-formed function is a non-trivial task; it may
> > even be undecidable. Really only the compiler knows where the function
> > boundaries lie, and it got it's knowledge from the program source
> > code, written by a human.
> If there is an indirect call opcode (necessary for function 
> pointers anyway), then the issue becomes whether the VM sees 
> code and data in a single address space.

No, the question is which arbitrary instruction represents a valid
function entry point. I assumed that the original question was posed
in the most general sense (can I take an arbitrary bunch of stuff out
of the code space and make it into a function), but as others (and I
indirectly) pointed out, you can define an opcode which defines
functions based on the machine representation of functions.

> I hope this was relevant. If not please elucidate.

Well, it made it clear that I didn't express myself clearly...

david rush
-- 
>From the start...the flute has been associated with pure (some might
say impure) energy. Its sound releases something naturally untamed, as
if a squirrel were let loose in a church." --Seamus Heaney