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.

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 @; # an unknown Text
  [("-- code call --\n") printList] !codeLocal # a non-NIL Code

  "-- 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

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