Re: Implementing a stack-based interpreter



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.
.



Relevant Pages

  • Re: C Expression Parsing in Forth?
    ... I've worked with enough different languages and methodologies over the years to know that *all* worthwhile programming is factoring, and that is completely independent of language. ... Any modern programmer who wants to remain relevant needs to understand the complete spectrum of factoring, not just low-level factoring in Forth, and not just the higher-level factorings the refactoring community has come up with. ... I do agree that the kind of factoring that happens in Forth is greatly facilitated by unnamed items on a stack. ...
    (comp.lang.forth)
  • Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP
    ... 20% are spurious errors produced by the type system, ... I am not writing a Stack. ... We were talking about mainstream languages like C++ and Java. ...
    (comp.object)
  • Re: Static vs. Dynamic typing (big advantage or not)---WAS: c.programming: OOP
    ... 20% are spurious errors produced by the type system, ... I am not writing a Stack. ... We were talking about mainstream languages like C++ and Java. ...
    (comp.programming)
  • C Expression Parsing in Forth?
    ... What value is there in programming in Forth ... >> a position on the stack. ... >syntax over time to where it'll do the entire c file. ... >> solution is to come up with a call interface between the two languages. ...
    (comp.lang.forth)
  • Re: How to make mod_lisp faster than php?
    ... There seem to be various levels of acceptance of deep recursion ... This applies to languages like C, ... Deep recursion works well: the stack size is not artificially ...
    (comp.lang.lisp)