Liking cljdoc? Tell your friends :D

fif.def


defcode-evalclj/s≠macro

clj
(defcode-eval name & body)
cljs
(defcode-eval &form &env name & body)

Allows you to define functions that contain fif code, which can then be passed through a fif stack machine to be evaluated.

Example:

(defcode-eval import-add2-library fn add2 + 2 endfn)

(def custom-stack-machine (-> fif.core/default-stack import-add2-library))

(fif.core/with-stack custom-stack-machine (fif.core/reval 2 add2)) ;; => '(4)

Allows you to define functions that contain fif code, which can then
be passed through a fif stack machine to be evaluated.

Example:

(defcode-eval import-add2-library
  fn add2
    + 2
  endfn)

(def custom-stack-machine
  (-> fif.core/*default-stack*
      import-add2-library))

(fif.core/with-stack custom-stack-machine
  (fif.core/reval 2 add2)) ;; => '(4)
source (clj)source (cljs)raw docstring

defstack-func-0clj/smacro

(defstack-func-0 name f)
source (clj)source (cljs)

defstack-func-1clj/smacro

(defstack-func-1 name f)
source (clj)source (cljs)

defstack-func-2clj/smacro

(defstack-func-2 name f)
source (clj)source (cljs)

defstack-func-3clj/smacro

(defstack-func-3 name f)
source (clj)source (cljs)

defstack-proc-0clj/smacro

(defstack-proc-0 name f)
source (clj)source (cljs)

defstack-proc-1clj/smacro

(defstack-proc-1 name f)
source (clj)source (cljs)

defstack-proc-2clj/smacro

(defstack-proc-2 name f)
source (clj)source (cljs)

defstack-proc-3clj/smacro

(defstack-proc-3 name f)
source (clj)source (cljs)

set-word-functionclj/s

(set-word-function sm wname wfunc & {:keys [doc group]})

Creates a new word function in sm with the symbol name wname and with the word function defined by wfunc.

Notes:

  • wfunc is a stack-machine function. Normal clojure functions can be turned into stack-machine functions via wrap-function-with-arity and wrap-procedure-with-arity.
Creates a new word function in `sm` with the symbol name `wname` and
with the word function defined by `wfunc`.

Notes:

- `wfunc` is a stack-machine function. Normal clojure functions can
be turned into stack-machine functions via
`wrap-function-with-arity` and `wrap-procedure-with-arity`.
sourceraw docstring

set-word-variableclj/s

(set-word-variable sm wname value & {:keys [doc group]})

Creates a new word variable in sm with the symbol name wname and with the value value. Optionally, you can include a docstring, and a group key.

Notes:

  • value is automatically wrapped for you. This is not the case with set-word-definition.
Creates a new word variable in `sm` with the symbol name `wname` and
with the value `value`. Optionally, you can include a docstring, and
a group key.

Notes:

- `value` is automatically wrapped for you. This is not the case
with `set-word-definition`.
sourceraw docstring

wrap-code-evalclj/s

(wrap-code-eval args)
source

wrap-function-with-arityclj/s

(wrap-function-with-arity num-args f)

Wraps a clojure function f which accepts num-args, and returns the function wrapped to be used in a stack machine.

The returned function accepts num-args values on the stack, drops num-args after processing the wrapped function, and pushes the result of (apply f args) back onto the stack.

Notes:

This wrapper always returns a result on the stack. If you do not wish to return a result, use fif.def/wrap-procedure-with-arity instead.

Examples:

(defn add2 [x] (+ x 2)) (def my-stack-machine (-> (fif.stack/new-stack-machine) (fif.stack/set-word 'add2 (fif.def/wrap-function-with-arity 1 add2)))) (fif.core/with-stack my-stack-machine (fif.core/reval 1 add2)) ;; => '(3)

Wraps a clojure function `f` which accepts `num-args`, and returns
the function wrapped to be used in a stack machine.

The returned function accepts `num-args` values on the stack, drops
`num-args` after processing the wrapped function, and pushes the
result of `(apply f args)` back onto the stack.

Notes:

This wrapper always returns a result on the stack. If you do not
wish to return a result, use `fif.def/wrap-procedure-with-arity`
instead.

Examples:

(defn add2 [x] (+ x 2))
(def my-stack-machine (-> (fif.stack/new-stack-machine)
                          (fif.stack/set-word 'add2 (fif.def/wrap-function-with-arity 1 add2))))
(fif.core/with-stack my-stack-machine
   (fif.core/reval 1 add2)) ;; => '(3)
sourceraw docstring

wrap-procedure-with-arityclj/s

(wrap-procedure-with-arity num-args f)

Wraps a clojure function f which accepts num-args, and returns the function wrapped to be used in a stack machine.

The returned function accepts num-args values on the stack, drops num-args after processing the wrapped function.

Notes:

This wrapper never returns a result on the stack. If you wish to return a result, use fif.def/wrap-function-with-arity instead.

Examples:

(def val (atom nil)) (defn set-val! [x] (reset! val x)) (def my-stack-machine (-> (fif.stack/new-stack-machine) (fif.stack/set-word 'set-val! (fif.def/wrap-procedure-with-arity 1 set-val!)))) (fif.core/with-stack my-stack-machine (fif.core/reval 1 set-val!) (deref val)) ;; => 1

Wraps a clojure function `f` which accepts `num-args`, and returns
the function wrapped to be used in a stack machine.

The returned function accepts `num-args` values on the stack, drops
`num-args` after processing the wrapped function.

Notes:

This wrapper never returns a result on the stack. If you wish to
return a result, use `fif.def/wrap-function-with-arity` instead.

Examples:

(def val (atom nil))
(defn set-val! [x] (reset! val x))
(def my-stack-machine (-> (fif.stack/new-stack-machine)
                          (fif.stack/set-word 'set-val!
                                              (fif.def/wrap-procedure-with-arity 1 set-val!))))
(fif.core/with-stack my-stack-machine
   (fif.core/reval 1 set-val!)
   (deref val)) ;; => 1
sourceraw docstring

wrap-variableclj/s

source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close