At 4:57 PM -0400 9/18/04, Matt Diephouse wrote:
On Fri, 17 Sep 2004 21:24:35 -0700, Steve Fink <[EMAIL PROTECTED]> wrote:
 On Sep-17, Matt Diephouse wrote:
 > o Calling subroutines from an eval creates a copy of the user stack,
 > so all changes are lost (rendering my Forth code unusable). Is this
 > behavior correct? If so, how should I go about this?

Dunno. Don't use an Eval? (Use a plain Sub or something instead)

I should have explained things a bit more clearly here. I have a PerlHash in forth.pir that contains a Sub for each supported operation. I store this as a global.

I then build up a string of PIR that locates subroutines from the
global PerlHash and invokes them. I compile this string and execute
it.

Every time I invoke one of the subroutines from the PIR string I've
compiled, I get a new copy of the user stack, which means that I am
unable to alter it with any of my subroutines.

Yeah, this'll happen, and it's an unintended side-effect of the changes in Parrot -- the User stack is essentially sub-local. That's good for a lot of things, but really, really messes up stack languages like Forth.


The only real option here is to maintain your own stack and leave its PMC in one of the registers.
--
Dan


--------------------------------------it's like this-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to