- 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.0450 : colon CORE
Skip leading space delimiters. Parse name delimited by a space. Create a definition for name, called a "colon definition". Enter compilation state and start the current definition, producing colon-sys. Append the initiation semantics given below to the current definition.
The execution semantics of name will be determined by the words compiled into the body of the definition. The current definition shall not be findable in the dictionary until it is ended (or until the execution of DOES> in some systems).
Initiation:
Save implementation-dependent information nest-sys about the calling definition. The stack effects i * x represent arguments to name.
name Execution:
Execute the definition name. The stack effects i * x and j * x represent arguments to and results from name, respectively.
See:
Rationale:
In Forth 83, this word was specified to alter the search order. This specification is explicitly removed in this standard. We believe that in most cases this has no effect; however, systems that allow many search orders found the Forth-83 behavior of colon very undesirable.
Note that colon does not itself invoke the compiler. Colon sets compilation state so that later words in the parse area are compiled.
Testing:
T{ NOP NOP1 NOP NOP2 -> }T
T{ NOP1 -> }T
T{ NOP2 -> }T
The following tests the dictionary search order:
ContributeContributions
ruv [128] Better wording for ColonProposal2020-02-06 02:14:04
ruv [130] The parts of execution semantics and the calling definitionRequest for clarification2020-02-21 15:32:19
Headnote
The specification says: a) Append the initiation semantics given below to the current definition. b) The execution semantics of name will be determined by the words compiled into the body of the definition.
Question I
Is the initiation semantics part of the execution semantics?
It seems yes, but slightly vague.
Since 1) These initiation semantics are not a word compiled into the body. And 2) "the current definition" and "the execution semantics of the current definition" is not the same.
Re 2: COMPILE,
appends execution semantics not just "to the current definition", but "to the execution semantics of the current definition". Perhaps it should be said somewhere that "appending semantics to the current definition" means appending these semantics to the execution semantics of the current definition. Or just use the same wording as in the specification for COMPILE,
.
Question II
What definition is a calling definition?
The initiation semantics is to save information about the calling definition. But it seems the standard nowhere says how to call a definition, or what definition is the calling definition.
EXECUTE
performs execution semantics.
COMPILE,
appends execution semantics.
EXIT
(and the code appended by Semicolon ;
) returns control to the calling definition.
But nobody calls the definition.
It looks like this issue reason is a gap between two different models (abstractions). We should find some bridge between this models, or use only one model.
NB: My interest is purely formal, it relates to the only wording of the specifications. From the implementation point of view, it's clear what definition is a calling definition. But the question is how to formulate it in the language of the Standard.
lmr [329] are colon-defs supposed to be compiled in data space?Request for clarification2024-01-05 17:07:09
This may be very basic, but: are colon-definitions supposed to be compiled in data space (addressable by @
, !
etc)? Can the thread of compiled XTs (or whatever the implementation uses) for a definition reside in some other address space, visible only to the inner interpreter or the equivalent? I suppose the answer is obvious, since presumably an implementation could compile everything to a primitive.