Proposal: Non parsing CREATE
This page is dedicated to discussing this specific proposal
ContributeContributions
GeraldWodni
[413] Non parsing CREATEProposal2025-09-16 11:19:01
Author:
Gerald Wodni
Change Log:
Problem:
There is no standard way to set the name of a word defined by create
via a string. However, each Forth system has such a word as a factor of create
.
Given that this functionality is exposed and documented, it is requested by some users. Personally I need it to create multiple words with a common prefix.
Solution:
Expose the underlying word(s) using a standard name.
- In VFXForth it is called
($create)
- In Gforth its equivalent is
nextname create
This gives the rationale for specific decisions you have taken in the proposal (often in response to comments), or discusses specific issues that have not been decided yet.
Typical use:
Create a store and fetch word pair for a register
32 buffer: next-name
: register: ( addr "prefix" -- )
\ *G create 2 words, with a common prefix
dup \ save address for both definitions
parse-name >r next-name r@ cmove \ save prefix
'!' r@ next-name + c! \ add '!' suffix
\ create store-word
next-name r@ 1+
[: ($create) , does> @ ! ;] execute
'@' r@ next-name + c! \ replace with '@' suffix
\ create fetch-word
next-name r> 1+
[: ($create) , does> @ @ ;] execute
;
variable uart-addr \ pretend to be a hardware register
uart-addr register: uart
'h' uart!
uart@ emit
Proposal:
Add a new word non-parsing-create
with references to create.
The behavior is like create except that the name is taken as a string ( caddr len -- )
form the stack instead of being parsed from the input stream.
Reference implementation:
System specific, hence standardization is required.