JanetDocsPlaygroundI'm feeling luckyGitHub sign in

compile



    cfunction

    (compile ast &opt env source)

    Compiles an Abstract Syntax Tree (ast) into a function. Pair the
    compile function with parsing functionality to implement eval.
    Returns a new function and does not modify ast. Returns an error
    struct with keys :line, :column, and :error if compilation fails.


2 examplesSign in to add an example
Loading...
(def ast '(print novar))
(def es (compile ast))
# => @{:column 11 :line 12 :error "unknown symbol novar"} returns struct with error on invalid ast
pepePlayground
(def cc (compile '(print "Janet"))) # => <function _thunk> on success returns function
(cc) # => prints Janet
pepePlayground