code?

code? (schema -- isBlock)

Inputs

Outputs

code? is a dereferenced-schema predicate. It tests whether the dereferenced schema is Block.

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

Ref inputs are followed before the test. Current value contents do not participate, and the result does not report general callability.

code? is not a general callability test. Use codeRef? for Code schemas and call to attempt an actual call.

Behavior

Example

"String" use

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

  "-- code? versus codeRef? --" printCompilerMessage
  [("-- block call --\n") printList] code? printStack _:;
  [("-- block call --\n") printList] codeRef? printStack _:;
  @codeLocal code? printStack _:;
  @codeLocal codeRef? printStack _:;

  "-- not a general callability test --" printCompilerMessage
  «1 +» code? printStack _:;
  textLocal code? printStack _:;

  [("-- block call --\n") printList] call
  @codeLocal call
  0
] "main" exportFunction

Module-loading wrapper lines are omitted below.

Expected Output During Compilation

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

Expected Output

-- block call --
-- code call --

See also