Liking cljdoc? Tell your friends :D

sci.core

The main SCI API namespace.

The main SCI API namespace.
raw docstring

*1clj/s

source

*2clj/s

source

*3clj/s

source

*eclj/s

source

add-class!clj/s

(add-class! ctx class-name class)

Adds class (JVM class or JS object) to ctx as class-name (a symbol). Returns mutated context.

Adds class (JVM class or JS object) to `ctx` as `class-name` (a
symbol). Returns mutated context.
sourceraw docstring

add-import!clj/s

(add-import! ctx ns-name class-name alias)

Adds import of class named by class-name (a symbol) to namespace named by ns-name (a symbol) under alias alias (a symbol). Returns mutated context.

Adds import of class named by `class-name` (a symbol) to namespace named by `ns-name` (a symbol) under alias `alias` (a symbol). Returns mutated context.
sourceraw docstring

add-js-lib!cljs

(add-js-lib! ctx name-str js-lib)

Add js library to context, so it can be used with require.

Add js library to context, so it can be used with `require`.
sourceraw docstring

add-namespace!clj/s

(add-namespace! ctx ns-name ns-map)

Adds namespace map ns-map named by the symbol ns-name to ctx. Returns mutated context.

Adds namespace map `ns-map` named by the symbol `ns-name` to
`ctx`. Returns mutated context.
sourceraw docstring

all-nsclj/s

(all-ns ctx)

Returns all SCI ns objects in the ctx

Returns all SCI ns objects in the `ctx`
sourceraw docstring

alter-var-meta!clj/s

(alter-var-meta! v f & args)

Atomically alter metadata for SCI Var v in its home world, or in the world selected by call-with-context. This is the portable host boundary; ClojureScript's native alter-meta! writes object fields directly.

Atomically alter metadata for SCI Var `v` in its home world, or in the
world selected by `call-with-context`. This is the portable host boundary;
ClojureScript's native `alter-meta!` writes object fields directly.
sourceraw docstring

alter-var-rootclj/s

(alter-var-root v f)
(alter-var-root v f & args)

Atomically alters the root binding of sci var v by applying f to its current value plus any args.

Atomically alters the root binding of sci var v by applying f to its
current value plus any args.
sourceraw docstring

assertclj/s

SCI var that represents SCI's clojure.core/assert

SCI var that represents SCI's clojure.core/*assert*
sourceraw docstring

bindingclj/smacro

(binding bindings & body)

Macro for binding sci vars. Must be called with a vector of sci dynamic vars to values.

Macro for binding sci vars. Must be called with a vector of sci
dynamic vars to values.
sourceraw docstring

call-with-contextclj/s

(call-with-context ctx f)

Invoke zero-argument host thunk f with ctx selected. Embeddings use this boundary when a stable inherited value must be read or mutated in a particular forked world.

Invoke zero-argument host thunk `f` with `ctx` selected. Embeddings use
this boundary when a stable inherited value must be read or mutated in a
particular forked world.
sourceraw docstring

capture-continuation-contextclj/s

(capture-continuation-context)
(capture-continuation-context ctx)

Capture the active SCI context and dynamic bindings for later continuation resumption. Must be called from managed SCI evaluation. The returned token is opaque; use continuation-context-fn to resume through it.

The explicit ctx arity is for host embedding boundaries invoked through an interpreted function after the top-level evaluation has returned.

Capture the active SCI context and dynamic bindings for later continuation
resumption. Must be called from managed SCI evaluation. The returned token is
opaque; use `continuation-context-fn` to resume through it.

The explicit `ctx` arity is for host embedding boundaries invoked through an
interpreted function after the top-level evaluation has returned.
sourceraw docstring

continuation-context-fnclj/s

(continuation-context-fn continuation-context f)

Return a function that invokes f with the SCI world and dynamic bindings represented by continuation-context.

Return a function that invokes `f` with the SCI world and dynamic bindings
represented by `continuation-context`.
sourceraw docstring

copy-nsclj/smacro

(copy-ns ns-sym sci-ns)
(copy-ns ns-sym sci-ns opts)

Returns map of names to SCI vars as a result of copying public Clojure vars from ns-sym (a symbol). Attaches sci-ns (result of sci/create-ns) to meta. Copies :name, :macro :doc, :no-doc and :argslists metadata.

Options:

  • :exclude: a seqable of names to exclude from the namespace. Defaults to none.

  • :copy-meta: a seqable of keywords to copy from the original var meta. Use :all instead of a seqable to copy all. Defaults to [:doc :arglists :macro].

  • :exclude-when-meta: seqable of keywords; vars with meta matching these keys are excluded. Defaults to [:no-doc :skip-wiki]

The selection of vars is done at compile time which is mostly important for ClojureScript to not pull in vars into the compiled JS. Any additional vars can be added after the fact with sci/copy-var manually.

Returns map of names to SCI vars as a result of copying public
Clojure vars from ns-sym (a symbol). Attaches sci-ns (result of
sci/create-ns) to meta. Copies :name, :macro :doc, :no-doc
and :argslists metadata.

Options:

- :exclude: a seqable of names to exclude from the
namespace. Defaults to none.

- :copy-meta: a seqable of keywords to copy from the original var
meta.  Use :all instead of a seqable to copy all. Defaults
to [:doc :arglists :macro].

- :exclude-when-meta: seqable of keywords; vars with meta matching
these keys are excluded.  Defaults to [:no-doc :skip-wiki]

The selection of vars is done at compile time which is mostly
important for ClojureScript to not pull in vars into the compiled
JS. Any additional vars can be added after the fact with sci/copy-var
manually.
sourceraw docstring

copy-varclj/smacro

(copy-var sym ns)
(copy-var sym ns opts)

Copies contents from var sym to a new sci var. The value ns is an object created with sci.core/create-ns.

On ClojureScript, when sym names a protocol (except cljs.core/IFn), the sci var holds a protocol entry instead of the raw protocol object. Sci code can then implement the protocol on deftype types, extend those with extend-type and use satisfies?. Host code calling protocol methods on such instances dispatches into the sci implementations.

Options (ignored for protocols):

  • :name: The name of the copied var. Defaults to the original var name.
  • :copy-meta-from: A symbol resolving to a var whose metadata (:doc, :arglists, :file, :line, :column) is used instead of sym's. Useful for wrapper vars that delegate to another var.
Copies contents from var `sym` to a new sci var. The value `ns` is an
object created with `sci.core/create-ns`.

On ClojureScript, when `sym` names a protocol (except `cljs.core/IFn`),
the sci var holds a protocol entry instead of the raw protocol object.
Sci code can then implement the protocol on `deftype` types, extend those
with `extend-type` and use `satisfies?`. Host code calling protocol
methods on such instances dispatches into the sci implementations.

Options (ignored for protocols):

- `:name`: The name of the copied var. Defaults to the original var name.
- `:copy-meta-from`: A symbol resolving to a var whose metadata (`:doc`,
  `:arglists`, `:file`, `:line`, `:column`) is used instead of `sym`'s.
  Useful for wrapper vars that delegate to another var.
sourceraw docstring

copy-var*clj/s

(copy-var* clojure-var sci-ns)

Copies Clojure var to SCI var. Runtime analog of compile time copy-var.

Copies Clojure var to SCI var. Runtime analog of compile time `copy-var`.
sourceraw docstring

create-nsclj/s

(create-ns sym)
(create-ns sym meta)

Creates namespace object. Can be used in var metadata.

Creates namespace object. Can be used in var metadata.
sourceraw docstring

disable-jitcljs

source

enable-unrestricted-access!clj/sdeprecated

(enable-unrestricted-access!)

Removed. Use the :unrestricted option of init or eval-string instead. Throws when called.

Removed. Use the `:unrestricted` option of `init` or `eval-string`
instead. Throws when called.
sourceraw docstring

errclj/s

SCI var that represents SCI's clojure.core/*err*

SCI var that represents SCI's `clojure.core/*err*`
sourceraw docstring

eval-formclj/s

(eval-form ctx form)

Evaluates form (as produced by parse-string or parse-next) in the context of ctx (as produced with init). To allow namespace switches, establish root binding of sci/ns with sci/binding or sci/with-bindings.

Evaluates form (as produced by `parse-string` or `parse-next`) in the
context of `ctx` (as produced with `init`). To allow namespace
switches, establish root binding of `sci/ns` with `sci/binding` or
`sci/with-bindings.`
sourceraw docstring

eval-stringclj/s

(eval-string s)
(eval-string s opts)

Evaluates string s as one or multiple Clojure expressions using the Small Clojure Interpreter.

The map opts may contain the following:

  • :namespaces: a map of symbols to namespaces, where a namespace is a map with symbols to values, e.g.: {'foo.bar {'x 1}}. These namespaces can be used with require.

  • :allow: a seqable of allowed symbols. All symbols, even those brought in via :namespaces have to be explicitly enumerated.

  • :deny: a seqable of disallowed symbols, e.g.: [loop quote recur].

  • :features: when provided a non-empty set of keywords, sci will process reader conditionals using these features (e.g. #{:bb}).

  • :ns-aliases: a map of aliases to namespaces that are globally valid, e.g. {'clojure.test 'cljs.test}

  • :interrupt-fn: a zero-arg fn called on every interpreted fn entry / loop entry

  • :unrestricted: when true, evaluated code may mutate built-in vars and CLJS instance interop skips :classes checks. Off by default. Applies only to this context: a context created during an unrestricted evaluation is sandboxed unless it also gets this option.

  • :fork-fn: optional one-argument host function used by fork to copy values held in SCI world cells that do not implement sci.fork/Forkable and need application-specific isolation. SCI-owned mutable primitives are already world-relative and retain identity.

  • :runtime-mode: :standard (the default) retains SCI's direct hot paths. :forkable enables isolated runtime worlds for Vars, dynamic bindings and SCI-owned mutable primitives.

  • :bindings: DEPRECATED - :bindings x is the same as :namespaces {'user x}.

Evaluates string `s` as one or multiple Clojure expressions using the Small Clojure Interpreter.

The map `opts` may contain the following:

- `:namespaces`: a map of symbols to namespaces, where a namespace
is a map with symbols to values, e.g.: `{'foo.bar {'x 1}}`. These
namespaces can be used with `require`.

- `:allow`: a seqable of allowed symbols. All symbols, even those
brought in via `:namespaces` have to be explicitly
enumerated.

- `:deny`: a seqable of disallowed symbols, e.g.: `[loop quote
recur]`.

- `:features`: when provided a non-empty set of keywords, sci will process reader conditionals using these features (e.g. #{:bb}).

- `:ns-aliases`: a map of aliases to namespaces that are globally valid, e.g. `{'clojure.test 'cljs.test}`

- `:interrupt-fn`: a zero-arg fn called on every interpreted `fn` entry / `loop` entry

- `:unrestricted`: when `true`, evaluated code may mutate built-in vars
and CLJS instance interop skips `:classes` checks. Off by default.
Applies only to this context: a context created during an unrestricted
evaluation is sandboxed unless it also gets this option.

- `:fork-fn`: optional one-argument host function used by `fork` to copy
values held in SCI world cells that do not implement `sci.fork/Forkable` and
need application-specific isolation. SCI-owned mutable primitives are
already world-relative and retain identity.

- `:runtime-mode`: `:standard` (the default) retains SCI's direct hot paths.
`:forkable` enables isolated runtime worlds for Vars, dynamic bindings and
SCI-owned mutable primitives.

- `:bindings`: DEPRECATED - `:bindings x` is the same as `:namespaces {'user x}`.
sourceraw docstring

eval-string*clj/s

(eval-string* ctx s)

Evaluates string s in the context of ctx (as produced with init).

Evaluates string `s` in the context of `ctx` (as produced with
`init`).
sourceraw docstring

eval-string+clj/s

(eval-string+ ctx s)
(eval-string+ ctx s opts)

Evaluates string s in the context of ctx (as produced with init).

Options: *:ns - the namespace to start evaluation in (defaults to the value of sci/ns)

Returns map with:

  • :val - the evaluated value
  • :ns - the namespace object
Evaluates string `s` in the context of `ctx` (as produced with
`init`).

Options:
*`:ns` - the namespace to start evaluation in (defaults to the value of `sci/ns`)

Returns map with:
* `:val` - the evaluated value
* `:ns` - the namespace object
sourceraw docstring

fileclj/s

SCI var that represents SCI's clojure.core/*file*

SCI var that represents SCI's `clojure.core/*file*`
sourceraw docstring

find-nsclj/s

(find-ns ctx ns-sym)

Returns SCI ns object as created with sci/create-ns from ctx found by ns-sym.

Returns SCI ns object as created with `sci/create-ns` from `ctx` found by `ns-sym`.
sourceraw docstring

forkclj/s

(fork ctx)
(fork ctx opts)

Forks a context (as produced with init) into an isolated runtime world.

Existing SCI Vars and SCI-created mutable primitives retain identity, but their values diverge after the fork. Host values may implement sci.fork/Forkable; opts may contain :fork-fn, which overrides the context's fallback function for other application-specific host values.

Forks a context (as produced with `init`) into an isolated runtime world.

Existing SCI Vars and SCI-created mutable primitives retain identity, but
their values diverge after the fork. Host values may implement
`sci.fork/Forkable`; `opts` may contain `:fork-fn`, which overrides the
context's fallback function for other application-specific host values.
sourceraw docstring

format-stacktraceclj/s

(format-stacktrace stacktrace)

Returns a list of formatted stack trace elements as strings from stacktrace.

Returns a list of formatted stack trace elements as strings from stacktrace.
sourceraw docstring

futureclj/smacro

(future & body)

Like clojure.core/future but also conveys sci bindings to the thread.

Like clojure.core/future but also conveys sci bindings to the thread.
sourceraw docstring

get-column-numberclj/s

(get-column-number reader)
source

get-line-numberclj/s

(get-line-number reader)
source

inclj/s

SCI var that represents SCI's clojure.core/*in*

SCI var that represents SCI's `clojure.core/*in*`
sourceraw docstring

initclj/s

(init opts)

Creates an initial sci context from given options opts. The context can be used with eval-string*. See eval-string for available options. The internal organization of the context is implementation detail and may change in the future.

Creates an initial sci context from given options `opts`. The context
can be used with `eval-string*`. See `eval-string` for available
options. The internal organization of the context is implementation
detail and may change in the future.
sourceraw docstring

internclj/s

(intern ctx sci-ns name)
(intern ctx sci-ns name val)

Finds or creates a sci var named by the symbol name in the namespace ns (which can be a symbol or a sci namespace), setting its root binding to val if supplied. The namespace must exist in the ctx. The sci var will adopt any metadata from the name symbol. Returns the sci var.

Finds or creates a sci var named by the symbol name in the namespace
ns (which can be a symbol or a sci namespace), setting its root
binding to val if supplied. The namespace must exist in the ctx. The
sci var will adopt any metadata from the name symbol.  Returns the
sci var.
sourceraw docstring

merge-optsclj/s

(merge-opts ctx opts)

Updates a context with opts merged in and returns it.

Updates a context with opts merged in and returns it.
sourceraw docstring

new-dynamic-varclj/s

(new-dynamic-var name)
(new-dynamic-var name init-val)
(new-dynamic-var name init-val meta)

Same as new-var but adds :dynamic true to meta.

Same as new-var but adds :dynamic true to meta.
sourceraw docstring

new-macro-varclj/s

(new-macro-var name init-val)
(new-macro-var name init-val meta)

Same as new-var but adds :macro true to meta as well as :sci/macro true to meta of the fn itself.

Same as new-var but adds :macro true to meta as well
as :sci/macro true to meta of the fn itself.
sourceraw docstring

new-varclj/s

(new-var name)
(new-var name init-val)
(new-var name init-val meta)

Returns a new sci var.

Returns a new sci var.
sourceraw docstring

normalize-metaclj/s

(normalize-meta m)
source

nsclj/s

SCI var that represents SCI's clojure.core/*ns*

SCI var that represents SCI's `clojure.core/*ns*`
sourceraw docstring

ns-nameclj/s

(ns-name sci-ns)

Returns name of SCI ns as symbol.

Returns name of SCI ns as symbol.
sourceraw docstring

outclj/s

SCI var that represents SCI's clojure.core/*out*

SCI var that represents SCI's `clojure.core/*out*`
sourceraw docstring

parse-nextclj/s

(parse-next ctx reader)
(parse-next ctx reader opts)

Parses next form from reader

Parses next form from reader
sourceraw docstring

parse-next+stringclj/s

(parse-next+string ctx reader)
(parse-next+string ctx reader opts)

Parses next form from reader

Parses next form from reader
sourceraw docstring

parse-stringclj/s

(parse-string ctx s)

Parses string s in the context of ctx (as produced with init).

Parses string `s` in the context of `ctx` (as produced with
`init`).
sourceraw docstring

pmapclj

(pmap f coll)
(pmap f coll & colls)

Like clojure.core/pmap but also conveys sci bindings to the threads.

Like clojure.core/pmap but also conveys sci bindings to the threads.
sourceraw docstring

SCI var that represents SCI's clojure.core/*print-dup*

SCI var that represents SCI's `clojure.core/*print-dup*`
sourceraw docstring

SCI var that represents SCI's cljs.core/*print-err-fn*

SCI var that represents SCI's `cljs.core/*print-err-fn*`
sourceraw docstring

SCI var that represents SCI's cljs.core/*print-fn*

SCI var that represents SCI's `cljs.core/*print-fn*`
sourceraw docstring

SCI var that represents SCI's clojure.core/*print-length*

SCI var that represents SCI's `clojure.core/*print-length*`
sourceraw docstring

SCI var that represents SCI's clojure.core/*print-level*

SCI var that represents SCI's `clojure.core/*print-level*`
sourceraw docstring

SCI var that represents SCI's clojure.core/*print-meta*

SCI var that represents SCI's `clojure.core/*print-meta*`
sourceraw docstring

SCI var that represents SCI's clojure.core/*print-namespace-maps*

SCI var that represents SCI's `clojure.core/*print-namespace-maps*`
sourceraw docstring

SCI var that represents SCI's cljs.core/*print-newline*

SCI var that represents SCI's `cljs.core/*print-newline*`
sourceraw docstring

SCI var that represents SCI's clojure.core/*print-readably*

SCI var that represents SCI's `clojure.core/*print-readably*`
sourceraw docstring

read-evalclj/s

SCI var that represents SCI's clojure.core/*read-eval*

SCI var that represents SCI's `clojure.core/*read-eval*`
sourceraw docstring

readerclj/s

(reader x)

Coerces x into indexing pushback-reader to be used with parse-next. Accepts: string or java.io.Reader.

Coerces x into indexing pushback-reader to be used with
parse-next. Accepts: string or java.io.Reader.
sourceraw docstring

reset-var-meta!clj/s

(reset-var-meta! v m)

Reset metadata for SCI Var v in its home or explicitly selected world.

Reset metadata for SCI Var `v` in its home or explicitly selected world.
sourceraw docstring

resolveclj/s

(resolve ctx sym)
source

retarget-continuation-contextclj/s

(retarget-continuation-context continuation-context target-ctx)

Copy a captured continuation context for target-ctx, which must belong to the same SCI lineage. The copy has independent dynamic binding boxes.

Copy a captured continuation context for `target-ctx`, which must belong to
the same SCI lineage. The copy has independent dynamic binding boxes.
sourceraw docstring

set!clj/s

(set! dynamic-var v)

Establish thread local binding of dynamic var

Establish thread local binding of dynamic var
sourceraw docstring

source-readerclj/s

(source-reader x)
source

stacktraceclj/s

(stacktrace ex)

Returns list of stacktrace element maps from exception, if available.

Returns list of stacktrace element maps from exception, if available.
sourceraw docstring

var->symbolclj/s

(var->symbol sci-var)

Returns a fully qualified symbol from a sci.lang.Var

Returns a fully qualified symbol from a `sci.lang.Var`
sourceraw docstring

with-bindingsclj/smacro

(with-bindings bindings-map & body)

Macro for binding sci vars. Must be called with map of sci dynamic vars to values. Used in babashka.

Macro for binding sci vars. Must be called with map of sci dynamic
vars to values. Used in babashka.
sourceraw docstring

with-detached-contextclj/s

(with-detached-context f)

Invoke zero-argument f outside the currently executing SCI context.

Embeddings use this host boundary when interpreted code recursively creates an independent SCI interpreter. The caller's active world and dynamic binding frame are restored even when f throws. Ordinary nested evaluation of an existing context does not need this function.

Invoke zero-argument `f` outside the currently executing SCI context.

Embeddings use this host boundary when interpreted code recursively creates
an independent SCI interpreter. The caller's active world and dynamic
binding frame are restored even when `f` throws. Ordinary nested evaluation
of an existing context does not need this function.
sourceraw docstring

with-in-strclj/smacro

(with-in-str s & body)

Evaluates body in a context in which sci's in is bound to a fresh StringReader initialized with the string s.

Evaluates body in a context in which sci's *in* is bound to a fresh
StringReader initialized with the string s.
sourceraw docstring

with-out-strclj/smacro

(with-out-str & body)

Evaluates exprs in a context in which sci's out is bound to a fresh StringWriter. Returns the string created by any nested printing calls.

Evaluates exprs in a context in which sci's *out* is bound to a fresh
StringWriter.  Returns the string created by any nested printing
calls.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close