- ABORT
- ABORT"
- ABS
- ACCEPT
- ACTION-OF
- AGAIN
- ALIGN
- ALIGNED
- ALLOT
- AND
- BASE
- BEGIN
- BL
- BUFFER:
- [
- [CHAR]
- [COMPILE]
- [']
- CASE
- C,
- CELL+
- CELLS
- C@
- CHAR
- CHAR+
- CHARS
- COMPILE,
- CONSTANT
- COUNT
- CR
- CREATE
- C!
- :
- :NONAME
- ,
- C"
- DECIMAL
- DEFER
- DEFER@
- DEFER!
- DEPTH
- DO
- DOES>
- DROP
- DUP
- /
- /MOD
- .R
- .(
- ."
- ELSE
- EMIT
- ENDCASE
- ENDOF
- ENVIRONMENT?
- ERASE
- EVALUATE
- EXECUTE
- EXIT
- =
- FALSE
- FILL
- FIND
- FM/MOD
- @
- HERE
- HEX
- HOLD
- HOLDS
- I
- IF
- IMMEDIATE
- INVERT
- IS
- J
- KEY
- LEAVE
- LITERAL
- LOOP
- LSHIFT
- MARKER
- MAX
- MIN
- MOD
- MOVE
- M*
- -
- NEGATE
- NIP
- OF
- OR
- OVER
- 1-
- 1+
- PAD
- PARSE-NAME
- PARSE
- PICK
- POSTPONE
- +
- +LOOP
- +!
- QUIT
- RECURSE
- REFILL
- REPEAT
- RESTORE-INPUT
- R@
- ROLL
- ROT
- RSHIFT
- R>
- SAVE-INPUT
- SIGN
- SM/REM
- SOURCE-ID
- SOURCE
- SPACE
- SPACES
- STATE
- SWAP
- ;
- S\"
- S"
- S>D
- !
- THEN
- TO
- TRUE
- TUCK
- TYPE
- '
- *
- */
- */MOD
- 2DROP
- 2DUP
- 2/
- 2@
- 2OVER
- 2R@
- 2R>
- 2SWAP
- 2!
- 2*
- 2>R
- U.R
- UM/MOD
- UM*
- UNLOOP
- UNTIL
- UNUSED
- U.
- U<
- U>
- VALUE
- VARIABLE
- WHILE
- WITHIN
- WORD
- XOR
- 0=
- 0<
- 0>
- 0<>
- \
- .
- <
- >
- <>
- #>
- <#
- #
- #S
- (
- ?DO
- ?DUP
- >BODY
- >IN
- >NUMBER
- >R
6.1.1780 LITERAL CORE
Interpretation:
Compilation:
Append the run-time semantics given below to the current definition.
Run-time:
Place x on the stack.
See:
Rationale:
Testing:
ContributeContributions
kumaym [353] compile semantics or compile action of literal wordRequest for clarification2024-07-29 13:31:50
it's said compile semantics ( x -- ) of literal is to compile the rutime semantics of place x on stack ( -- x ) , in other words the action literal is supposed to do in compilation state is to compile a literal in the definition of currently defining word, and the literal compiled is obtained from the stack at the moment literal is executed (or compiled since it is a immediate word).
so,
: foo [ 4 ] literal ;
is supposed to define a word foo as having 4 in its body, and that's true
see foo
: foo 4 ; ok
following the compilation of foo step by step we first create a word foo then switch to interpretation mode and push 4 to the stack and then go back to compilation mode to compile literal witch being an immediate word gets executed just to compile 4 (what is on the stack) to the definition of foo and then ; ends the definiton, getting a word containing 4 in its body.
But, then shouldn't be equivalent these two definitions?
: foo [ 4 ] literal ;
4 : foo literal ;
so strange they're not, the first one is ok but the last one gives this error in gforth:
*the terminal*:20:17: error: Control structure mismatch
4 : foo literal >>>;<<<
Backtrace:
kernel/cond.fs:114:26 0 $6FFFFF810200 throw
glocals.fs:635:5 1 $6FFFFF821AB0 ?struc
kernel/comp.fs:773:5 2 $6FFFFF806BF0 ;-hook
why?