codeRef?

codeRef? (schema -- isCode)

Inputs

Outputs

codeRef? is a dereferenced-schema predicate. It tests whether the dereferenced schema is Code.

The name is historical: codeRef? is the Code test, while code? is the Block test.

Ref inputs are followed before the test. Current value contents do not participate, and the result does not distinguish known NIL Code, unknown Code, and usable non-NIL Code values.

codeRef? is not a usability test. Known NIL, unknown, and usable non-NIL Code values all still report TRUE because only the schema participates.

Behavior

Example

"String" use

{} 0 {} [
  codeLocal: {} () {} codeRef;
  [("-- code call --\n") printList] !codeLocal

  "-- codeRef? versus code? --" printCompilerMessage
  {} () {} codeRef codeRef? printStack _:;
  {} () {} codeRef code? printStack _:;
  @codeLocal codeRef? printStack _:;
  @codeLocal code? printStack _:;

  "-- not a general callability test --" printCompilerMessage
  {} () {} codeRef dynamic codeRef? printStack _:;
  [] codeRef? printStack _:;
  «1 +» codeRef? printStack _:;

  @codeLocal call
  0
] "main" exportFunction

Module-loading wrapper lines are omitted below.

Expected Output During Compilation

-- codeRef? versus code? --
TRUE
FALSE
TRUE
FALSE
-- not a general callability test --
TRUE
FALSE
FALSE

Expected Output

-- code call --

See also