name" -- xt )">

' - CORE (original) (raw)

6.1.0070 ' tick CORE

( "name" -- xt )

Skip leading space delimiters. Parse name delimited by a space. Find name and return xt, the execution token for name. An ambiguous condition exists if_name_ is not found. When interpreting,' xyz EXECUTE is equivalent to xyz.

See:

Rationale:

Typical use: ... ' name.

Many Forth systems use a state-smart tick. Many do not. Forth-2012 follows the usage of Forth 94.

Testing:

T{ : GT1 123 ; -> }T
T{ ' GT1 EXECUTE -> 123 }T

ContributeContributions

JohanKotlinskiavatar of JohanKotlinski [11] Request for clarification2015-12-25 23:32:43

"An ambiguous condition exists if name is not found. When interpreting, ' xyz EXECUTE is equivalent to xyz."

Which of these two statements have precedence? I.e., if xyz is not found, should ' xyz EXECUTE be equivalent to xyz or will it cause an ambiguous condition?

Reply New Version

ruvavatar of ruv [96] Ambiguous condition in case of undefined execution semanticsComment2019-07-16 15:12:55

1. By the definition, an execution token identifies some execution semantics.

2. The specification of this word (i.e. Tick ') implies that when a word has execution semantics it shall have the interpretation semantics too, and performing its execution semantics in interpretation state shall be identical to performing its interpretation semantics.

3. But this specification does not imply the inverse — that if a word has the interpretation semantics it shall have execution semantics too. For example 123 has the interpretation semantics, but it may not have execution semantics. In such case Tick cannot return any meaningful xt for it.

NB: IIRC in some Forth systems Tick and FIND can return meaningful xt for the numbers (but in any case, such Forth system can be easily implemented).

4. Therefore, an ambiguous condition should exist if ' is applied to a word with undefined execution semantics (i.e. when the standard does not explicitly specify execution semantics). The examples of such words are: dual-semantics words like TO, S", the words with undefined interpretation semantics like IF, the numbers.

Reply New Version

JimPetersonavatar of JimPeterson [176] Is Tick Immediate?Request for clarification2021-01-22 02:52:22

I'm confused. Is ' an immediate word or not?

If I do:

: test ' DUP ;
1 test SWAP

Do I get:

( xtD 1 )

where xtD is the execution token of DUP that got swapped with the 1, or do I get:

( 1 xtS xtS )

where xtS is the execution token of SWAP that got duplicated?

The existence of ['] certainly implies that ' is not immediate, and that if you want to have an immediate effect, you should use [']. Maybe that's what the documentation is trying to imply by not having separate "Compilation:" and "Runtime:" sections for this word? Many of the simpler words don't have such sections. Still, it may be better to explicitly state when the parsing and finding occurs... just for the sake of clarity. Maybe add another test to the "Testing:" section?

Reply New Version

ruvavatar of ruv [346] Eliminating ambiguous conditions for TickRequest for clarification2024-06-20 15:25:45

I'm interested in how we want to define Tick's behavior in edge cases, as part of the general trend of reducing the number of ambiguous conditions.

Undefined word

When a word is not found (regardless of STATE), Tick shall throw an exception -13 ("undefined word"). It's obvious.

Undefined interpretation semantics

When interpretation semantics for the word are not defined by the standard, Tick shall do one from the following options:

This case is for the words like if, >r, exit, begin, etc.

Interpretation semantics are defined, but execution semantics undefined

The main question is this: should we allow Tick to throw an exception if interpretation semantics for the word are defined, but execution semantics are not defined?

At the moment, it's for the five standard words: s", s\", to, is, action-of.

Most systems in this case return xt that, when executed in interpretation state, performs the interpretation semantics for the word. Behavior in compilation state vary from system to system. So, by the fact, an ambiguous condition exists only when this xt is executed in compilation state.

What do you think?

Reply New Version