I was thinking about parsing them as strings, but that would make viewing and debugging the code difficult. I was really hoping for translating the compile-time code into the run-time code I have presented.
I made some code examples that I would like to obtain some feedback on. Tell me which of these run-time code examples seems the most plausible to work.
Example 1:
compile-time code:
: myword { ; dog cat hamster }
4 -> dog
3 -> cat
1 -> hamster
dog @ cat @ +
hamster @ +
cr " animals = " . cr
;
run-time code:
: myword
\ Note: myword_wordlist and standardlist are raw numbers - not variables
myword_wordlist standardlist 2 set-order \ setup dictionary search order
definitions
variable dog
variable cat
variable hamster
4 dog !
3 cat !
1 hamster !
dog @ cat @ +
hamster @ +
cr " animals = " . cr
standardlist 1 set-order \ restore dictionary search order
definitions
;
Another possible run-time code translation:
: myword
variable dog
variable cat
variable hamster
4 dog !
3 cat !
1 hamster !
dog @ cat @ +
hamster @ +
cr " animals = " . cr
forget dog
forget cat
forget hamster
;
Example 2:
compile-time code:
\ assigning top stack value to variables
: myword { dog cat hamster }
dog @ cat @ +
hamster @ +
cr " animals = " . cr
;
run-time code:
: myword
variable dog
variable cat
variable hamster
dog !
cat !
hamster !
dog @ cat @ +
hamster @ +
cr " animals = " . cr
forget dog
forget cat
forget hamster
;