- 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.
kumaym [354] definion and use of colon-sys and nest-sysRequest for clarification2024-08-04 19:34:46
This text is for clarification of the intended use of colon-sys and nest-sys and also its use taking into account the differents steps or phases involved.
I will expose my understandings and more probably my misuderstanding about this in order to get knowledge and clarify. Maybe my confussion is related to the way it is redacted or maybe to my lack of knowledge.
The questions I want to get clarified for colon-sys and nest-sys are basically:
- semantics and definition
- implementation
- need to be defined as a concept in the standard
- semantics in terms of compile time and excution time
You can follow the comments in word literal about this issue but it's not necessary for the following discussion
- semantics and definition
The only place in standard where I can find a kind of definition is in 3.1 Data types where it is said that both colon-sys and nest-sys datatypes are implementation dependent and define colon-sys as a "definition compilation". The same for nest-sys which is defined in the same place as "definition cells" which I find confuse since it doesn't even mention is a return address or a return from call
I couldn't find any rule or requisite relative to colon-sys or nest-sys wich has sense since it is implementation dependent but then why to mention?
What I supposed is colon-sys is an abstract concept refering to a word definition meaning more or less all the stuff needed to start a definition leaving its real meaning to implementation, similar for nest-sys
- implementation
Anyway colon-sys is a real thing which is pushed in data stack (or control-flow stack if any) so I think it should be precissely defined, in particular this page says colon word "Enter compilation state and start the current definition, producing colon-sys", producing colon-sys suggests to me there is something real. It could be said colon-sys may be zero length and thus it produces nothing, this is implementation dependant, but then if size, structure and meaning of colon-sys it totally implementation defined, why to even mention it in the standar? it's implementation dependant.
There are at least two questions interesting to know about the colon-sys and nest-sys implementation:
- where is it stored? i.e. is it possible to access to the colon-sys object if needed or it only leaves temporaly on stack? is it a first class object?
- since it is on stack on word definition time, may a word definition a stack is empty or has to assume there's always a colon-sys object even if being zero sized?
- need to be defined as a concept in the standard
the mission of colon word is to create a new entry in the dictionary filling all slots and start to compile each xt it encounters in definition to dictionary area pointed by HERE. My understandin is all those steps can be done without polluting the stack from the point of view of definition words. At the time colon word starts compiling the words in the definition, the stack shoud be untouched so words in definition list can assume stack is "clear" (empty or with data pushed for last word execute prior to excute colon word) Finally, word ; just have to compile EXIT and switch to interpretation state, again it doesn't need anything in the stack to do its action.
So I think it's not necessary to define colon-sys or nest-sys in the standard since it is completely implementation dependant and thus it should be a black box.
The only reason to define or use a colon-sys concept is as a flag to users to take into acount than you have to assume stack is "polluted" into a defined word and you shouldn't assume nothing about the stack and in particular you shouldn't assume it is empty or under you control. In fact you should assume there's stuff on the stack when inside a definition and everything needed on the stack whould be pushed inside the definition.
- semantics in terms of compile time and excution time
In this page about word colon it is said:
( C: "<spaces>name" -- colon-sys ) 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).
The use of C: confuses me, I understand it as taking about compilation semantics, the "C:" in the stack comment.
But reading carefully I think C: really means control-flow stack rather tha compilaton semantics, and there's no Compilation section because word colon has no compilation semantics.
I think it shoud be interpretation semantics because the behaviour describes is runtime behaviour, what word colon does when executed:
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.
Anyway, assuming interpretation semantics, my problem is with the sentence
Append the initiation semantics given below to the current definition.
what I understand for "append the initiation semantics to the current definition" is to compile the initiation semanctics to the current definition, but if doing so you should see the initiation semantics in the definition list when you perform a see on the defined word, since it is compiled there otherwise, if to append the initiation semantics really means to execute the initiation semantics I think it is redacted not quite clear.
but sure I misunderstood it and really it's all about interpretation semantics because being that initiation semantics is written as:
Initiation: ( i * x -- i * x ) ( R: -- nest-sys ) Save implementation-dependent information nest-sys about the calling definition. The stack effects i * x represent arguments to name.
I undestand initiation is a interpretation semantics, part of interpretion semantics of colon word, it is talking about the behaviour when you're going to execute a word in the definition list in order to save the return address (nest-sys strcuture)
Maybe everything will be more clear including a Compilation sections stating there¡s no compilation semantics and thus everything in the page refers to interpreation semantics
In a first reading I was assuming Initiation semantics is compiled into definied word because "append initiation semantics to current definition" sounds to me the same as "compile initiation semantics into current definition"
Under this assumption I was supposing nest-sys is about nested definitions, and since nested definition of colon words are not allowed in forth, I supposed it was related to quotations since you "compile" a quotation is some way inside a current definition.