Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In order.fth, replace some uses of @/! with token@/token! #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ellerh
Copy link

@ellerh ellerh commented Dec 2, 2016

I'm proposing some changes to order.fth. I don't claim to understand the code but with the changes my test program goes a little bit further; even with the changes there are still problems with wordlists.

@@ -16,13 +16,13 @@ also root definitions
: set-order ( wid1 .. widn n -- )
context /context erase
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try replacing the above line with
context /context bounds ?do i !null-token /token +loop

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this, but it didn't make a difference. It seems that token@ treats 0 specially.

However, after re-using the code from vocabulary to initialize wordlists (in commit 7f17bde) everything seems to work as it should.

* src/cforth/util.fth ((init-wordlist)): Factored out from VOCABULARY.
(vocabulary): Use it.

* src/cforth/order.fth (wordlist): Use (init-wordlist).
(set-order): Inititialize more cleanly.
@MitchBradley
Copy link
Owner

I just pushed a couple of commits that incorporate your fixes with a slightly different factoring. Let me know if it works for you.

@ellerh
Copy link
Author

ellerh commented Dec 7, 2016

I just pushed a couple of commits that incorporate your fixes with a slightly different factoring.

Yes, this is nicer.

Let me know if it works for you.

I think some of the @/! -> token@/token! replacements are needed because the following examples don't work:

shell> cforth
C Forth  Copyright (c) 2008 FirmWorks
ok wordlist set-current order
context: forth forth root     current: Address exception
shell> cforth
C Forth  Copyright (c) 2008 FirmWorks
ok get-order swap drop wordlist swap set-order
ok order
Address exception

In the following example get-order should only return 3 items instead of 10:

shell> cforth
C Forth  Copyright (c) 2008 FirmWorks
ok order
context: forth forth root     current: forth 
ok get-order .s
7f47271ff6f0 7f47271f8010 7f47271f8010 7f47271f8010 7f47271f8010 7f47271f8010 7f47271f8010 7f47271f8010 7f47271f8010 7f47271f8010 7f47271f8010 7f47271f8010 7f47271f8010 7f47271f8010 7f47271f86e0 7f47271f86e0 10 
ok 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants