Skip to content

Instantly share code, notes, and snippets.

@ruv ruv/spec-for-find.variant-a.md Secret
Last active Mar 16, 2020

Embed
What would you like to do?
Proposal, specification for FIND

(version A)


FIND

( c-addr -- c-addr 0 | xt n )

Find the definition name whose name matches the counted string at c-addr. If the definition is not found, return c-addr and zero. Otherwise the definition is found, return xt and n, where xt is the execution token for name, and n is 1 or -1. If name has other than default interpretation semantics, all the returned values may differ between interpretation and compilation state; otherwise they are the same.

When the definition is found in interpretation state: if the definition is immediate then n is 1, otherwise n is -1; performing xt in intepretation state performs the interpretation semantics for name.

When the definition is found in compilation state: if n is -1, appending the execution semantics identified by xt to the current definition performs the compilation semantics for name, otherwise performing xt in compilation state performs the compilation semantics for name.

An ambiguous condition exists if xt returned by FIND is performed in the conditions that are not met the conditions specified above.


"Performing xt" means performing the execution semantics identified by the execution token xt.

A definition has default interpretation semantics if and only if the "Interpretation:" section is absent in the corresponding glossary entry, and the "Execution:" section is present. Default interpretation semantics for a definition is to perform its executin semantics in interpretation state (see also 3.4.3.2).

(version B)


FIND

( c-addr -- c-addr 0 | xt n )

Find the definition name whose name matches the counted string at c-addr. If the definition is not found, return c-addr and zero. Otherwise the definition is found, return xt and n.

If name has default interpretation semantics, xt is the execution token for name, and n is 1 if name is immediate word, -1 otherwise. The returned values are the same regardless whether the definition is found in interpretation state or in compilation state.

If name has other than default interpretation semantics, xt is the execution token for an unspecified implementation-dependent definition, and n is 1 or -1, and the following conditions are met.

  1. When the definition is found in compilation state: if n is 1, performing xt in compilation state performs the compilation semantics for name, otherwise n is -1, and appending the execution semantics identified by xt to the current definition performs the compilation semantics for name.

  2. When the definition is found in interpretation state: if n is 1, xt and n are the same when the definition is found in compilation state, otherwise n is -1, and both xt and n may be different when the definition is found in compilation state; performing xt in intepretation state performs the interpretation semantics for name.

  3. The definition may be not found in interpretation state but found in compilation state, and vise versa. Also a definition may be not found at all.

An ambiguous condition exists if xt is performed in the conditions that are not met the conditions specified above.


"Performing xt" means performing the execution semantics identified by the execution token xt.

A definition has default interpretation semantics if and only if the "Interpretation:" section is absent in the corresponding glossary entry, and the "Execution:" section is present (see also 3.4.3.1). Default interpretation semantics for a definition is to perform its executin semantics in interpretation state (see also 3.4.3.2).

If interpretation semantics are undefined for a definition, a Forth system is allowed to provide implementation-defined interpretation semantics for this definition (see A.3.4.3.2). In such case, when the definition is found in interpretation state, performing the returned xt in intepretation state performs the implementation-defined interpretation semantics for name.

A program is allowed to apply FIND to any string. A definition may be not found even if a Forth system provides interpretation or compilation semantics for the corresponding name.

@ruv

This comment has been minimized.

Copy link
Owner Author

ruv commented Oct 23, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.