eval, reval

Evaluate a parse tree

eval

Syntax: eval x, eval[x]

Where x is a parse tree, returns the result of evaluating it.

The eval function is the complement of parse and can be used to evaluate the parse trees it returns. (Also parse trees constructed explicitly.)

q)parse "2+3"
+
2
3
q)eval parse "2+3"
5
q)eval (+;2;3)      / constructed explicitly
5


reval

Syntax: reval x, reval[x]

The reval function is similar to eval, and behaves as if the command-line option -b were active during evaluation.

An example usage is inside the message handler .z.pg, useful for access control, here blocking sync messages from updating:

q).z.pg:{reval(value;enlist x)} / define in process listening on port 5000
q)h:hopen 5000 / from another process on same host
q)h"a:4"
'noupdate: . a