Re: Implementing a stack-based interpreter
- From: Tony Finch <dot@xxxxxxxx>
- Date: 26 Jul 2005 13:21:37 -0400
Alex McDonald <ar.mcdonald@xxxxxxxxxx> wrote:
>
>One stack isn't quite enough, btw, unless you're interpreter is for a
>simple RPN calculator; Forth uses two, one for data and one for return
>addresses of called subroutines (called words in Forth).
>
>[One stack is enough if you have a simple enough procedure call without
>variable length argument lists and the like. -John]
In languages like Forth and Postscript where the operand stack is
explicit in the language, it is still usual for the call stack to
remain implicit. In languages like C and Pascal the details of the
stack are an implementation matter, but there's usually a single
combined stack. Functional programming implementations may be
no-stack (call frames on the heap), single-stack, or dual-stack. You
can convert a dual-stack implementation into a single-stack
implementation using continuation conversion, which makes the implicit
return address into an explicit operand. I don't know if any Forth
variants have been based on this idea.
Tony.
--
f.a.n.finch <dot@xxxxxxxx> http://dotat.at/
BERWICK ON TWEED TO WHITBY: NORTH 3 OR 4 BECOMING VARIABLE 3. SCATTERED
SHOWERS. GOOD. SLIGHT.
.
- References:
- Implementing a stack-based interpreter
- From: cvrebert
- Re: Implementing a stack-based interpreter
- From: Alex McDonald
- Implementing a stack-based interpreter
- Prev by Date: How eleminate epsilon
- Next by Date: Re: how to eliminate this left recursion
- Previous by thread: Re: Implementing a stack-based interpreter
- Next by thread: Re: Implementing a stack-based interpreter
- Index(es):
Relevant Pages
|
|