Proposal: A better approach for SYNONYM wording
This page is dedicated to discussing this specific proposal
ruv
[309] A better approach for SYNONYM wordingProposal2023-09-22 17:06:27
Rationale
Instead of mentioning SYNONYM in many other glossary entries, it's better to use another wording, which does not require that.
In some cases, it's better to specify a glossary entry in a more general manner, than mention SYNONYM in it (see the proposal below).
According to 2.2.3 Parsed-text notation, "name" has the specified meaning when it's mentioned literally as "name" only. So, newname and oldname are not normative. Probably, we can use indexing as for data type symbols in stack diagrams. When an index not a number, it is concatenated via a dot.
We should ensure that system-defined semantics are the same for synonyms.
If the standard defines some semantics, system-defined semantics shall be equivalent to them, so it's enough to mention system-defined semantics.
In some plausible Forth system implementations the execution token for a word
is identical to the name token for this word,
and the execution tokens for the different words are always different. So
SYNONYM should not require the same execution token (if any) for name.new and name.old.
The part about deferred words is not enough formal.
Examples
A synonym of the word CREATE creates a word with the data field address due to the same execution semantics as of CREATE:
synonym mycreate create
mycreate foo 123 ,
A synonym of a word created via performing the execution semantics of CREATE returns the same data field address due to the same execution semantics as the original word:
synonym bar foo
bar foo = . \ prints -1
Consequently, the execution token for a synonym is associated with the same data field address (if any) as the xt of the original word:
' bar >body ' foo >body = . \ prints -1
A synonym of a word created via performing the execution semantics of VALUE returns the same value due to the same execution semantics as the original word:
1 value x
synonym y x
x y = . \ prints -1
Applying TO to a synonym of a word created via performing the execution semantics of VALUE changes the value assigned to the original word due to the same TO name Run-time semantics:
2 to y
x y = . \ prints -1
Proposal (draft)
Re data-field address
In
6.1.0550 >BODY,
6.1.1250 DOES>,
Replace the phrase:
defined via
CREATE
by the phrase:
defined via performing
CREATEexecution semantics
Replace the phrase:
defined with
CREATEor a user-defined word that callsCREATE.
by the phrase:
defined via performing
CREATEexecution semantics
Re deferred words
In
6.2.1725 IS,
6.2.0698 ACTION-OF,
6.2.1177 DEFER@,
6.2.1175 DEFER!,
Replace the phrase:
defined by
DEFER
by the phrase:
defined via performing
DEFERexecution semantics
Re SYNONYM
Replace the whole normative part of the glossary entry 15.6.2.2264 SYNONYM by the following paragraphs:
( "<spaces>name.new" "<spaces>name.old" -- )
Skip leading space delimiters, parse name.new delimited by a space, skip leading space delimiters, parse name.old delimited by a space.
Find name.old. Create a definition for name.new with the semantics defined below; name.new may be the same as name.old.
The execution token for name.new may differ from the execution token for name.old.
An ambiguous condition exists if name.old is not found or IMMEDIATE is performed when name.new is the most recent definition.
All the ambiguous conditions that exist when using name.old, also exist when using name.new.
If execution semantics are defined by the system for name.old:
name.new Execution: Perform the execution semantics of name.old.
If interpretation semantics are defined by the system for name.old:
name.new Interpretation: Perform the interpretation semantics for name.old.
If compilation semantics are defined by the system for name.old:
name.new Compilation: Perform the compilation semantics for name.old.
If "TO name.old Run-time" semantics are defined for name.old:
TO name.new Run-time: Perform TO name.old Run-time semantics.
If name.old are defined via performing the execution semantics of DEFER:
IS name.new
performs IS name.old
ACTION-OF name.new
performs ACTION-OF name.old
Applying DEFER@ to the xt of name.new
performs DEFER@ to the xt of name.old
Applying DEFER! to the xt of name.new
performs DEFER! to the xt of name.old