Catch duplicates throw code under certain conditons

18 views
Skip to first unread message

Frank Ruben

unread,
Jan 30, 2017, 3:20:35 PM1/30/17
to pforthdev
Hi all,

I have a surprising phenomenon best explained by two code samples.

This one works as expected:

: foo-throw -888 .s throw ;
: foo-catch ['] foo-throw catch .s ;
0sp foo-catch

and yields:

Stack<10> -888
Stack<10> -888


When I complicate the invocation by passing another xt to the called word (in the real code I'm doing this for a reason), I will receive the throw code twice on the catch side, like so:

: bar-doit  ( -- )    ." doing it!" cr ;
: bar-throw ( xt -- ) execute -999 .s throw ;
: bar-catch ( -- )    ['] bar-doit  ['] bar-throw  catch .s ;
0sp bar-catch

which yields:

doing it!
Stack<10> -999
Stack<10> -999 -999


Is this expected and I don't see something obvious or if not is there a workaround?

Thanks, Frank

Helmut Eller

unread,
Jan 31, 2017, 2:11:42 AM1/31/17
to Frank Ruben, pforthdev
On Mon, Jan 30 2017, Frank Ruben wrote:

> Is this expected and I don't see something obvious or if not is there
> a workaround?

I think it's the same bug that I tried to fix with this patch:
http://github.com/ellerh/pforth/commit/04dbf79ab9bde0e3bcd088f551ce1944bdbdade1

That branch contains a number of other fixes/improvements that I haven't
made yet into proper pull requests.

Helmut

Phil Burk

unread,
Feb 4, 2017, 6:44:47 PM2/4/17
to pforthdev
Hello Frank,

Thanks for reporting this. It does sound like a bug. I'm glad to see Helmut may already have a simple fix. Have you tried it?

Feel free to add a bug report so we don't lose track of this:


Phil Burk



--
You received this message because you are subscribed to the Google Groups "pforthdev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pforthdev+unsubscribe@googlegroups.com.
To post to this group, send email to pfor...@googlegroups.com.
Visit this group at https://groups.google.com/group/pforthdev.
For more options, visit https://groups.google.com/d/optout.

Frank Ruben

unread,
Feb 5, 2017, 8:40:22 AM2/5/17
to pforthdev, frankr...@gmail.com

 Thanks Helmut,

I did compile your commit 04dbf79 and ran the test case on the new executable, but still got the same result as shown above.
I'll create an issue in Phil's repo.

Schönen Sonntagnachmittag, Frank


Frank Ruben

unread,
Feb 5, 2017, 9:16:25 AM2/5/17
to pforthdev, phil...@mobileer.com


On Sunday, February 5, 2017 at 12:44:47 AM UTC+1, Phil Burk wrote:
Hello Frank,

Thanks for reporting this. It does sound like a bug. I'm glad to see Helmut may already have a simple fix. Have you tried it?

Feel free to add a bug report so we don't lose track of this:


Phil Burk


Hi Phil,

thanks for taking care.
I created a new issue , also mentioning that Helmut's fix did not help here.

The workaround for now simply is to drop the complete stack after processing the throw code,
that is good enough for the moment.

Thanks again, Frank

Reply all
Reply to author
Forward
0 new messages