Skip to content

Using MARKER within a colon definition? #133

Answered by ruv
SirWumpus asked this question in Q&A
Discussion options

You must be logged in to vote

A simple solution is to use evaluate:

: test_group ... "marker rm_test_group" evaluate ... ;
: test_group_end ... "rm_test_group" evaluate  ;

Or execute-parsing in the first case:

: test_group "rm_test_group" ['] marker execute-parsing ... ;

The original code:

: test_group ... MARKER rm_test_group ... ;
: test_group_end ... rm_test_group ;

is not correct due to the following problems:

  1. The word marker is an ordinary word. Therefore it doesn't parse anything when it's used inside a definition (i.e., when it's compiled), — just like constant and : (colon). So the Forth text interpreter will encounter rm_test_group and raise an error.
  2. When test_group_end is being defined, rm_test_group

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@SirWumpus
Comment options

Comment options

You must be logged in to vote
1 reply
@SirWumpus
Comment options

Answer selected by SirWumpus
Comment options

You must be logged in to vote
1 reply
@ruv
Comment options

ruv Jan 26, 2023
Maintainer

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question technique Patterns and use cases
4 participants