Janet Language Documentation
Description: API Documentation for the janet programming language.

# Janet Core API

Version 1.42.0-7fd75f34

Generated September 1, 2026 at 05:02:47

## %

function

(% & xs)
Returns the remainder of dividing the first value of xs by each remaining value.

## %=

macro

(%= x & ns)
Shorthand for (set x (% x n)).

boot.janet (144:1)

## *

function

(* & xs)
Returns the product of all elements in xs. If xs is empty, returns 1.

## *=

macro

(*= x & ns)
Shorthand for (set x (\* x n)).

boot.janet (142:1)

## *args*

keyword

Dynamic bindings that will contain command line arguments at program start.

boot.janet (4955:1)

## *current-file*

keyword

Bound to the name of the currently compiling file.

boot.janet (1502:1)

## *debug*

keyword

Enables a built in debugger on errors and other useful features for debugging in a repl.

boot.janet (1497:1)

## *defdyn-prefix*

keyword

Optional namespace prefix to add to keywords declared with `defdyn`.
Use this to prevent keyword collisions between dynamic bindings.

boot.janet (1492:1)

## *doc-color*

keyword

Whether or not to colorize documentation printed with `doc-format`.

boot.janet (3581:1)

## *doc-width*

keyword

Width in columns to print documentation printed with `doc-format`.

boot.janet (3578:1)

## *err*

keyword

Where error printing prints output to.

boot.janet (1495:1)

## *err-color*

keyword

Whether or not to turn on error coloring in stacktraces and other error messages.

boot.janet (2812:1)

## *executable*

keyword

Name of the interpreter executable used to execute this program. Corresponds to `argv[0]` in the call to
`int main(int argc, char **argv);`.

boot.janet (4958:1)

## *exit*

keyword

When set, will cause the current context to complete. Can be set to exit from repl (or file), for example.

boot.janet (1498:1)

## *exit-value*

keyword

Set the return value from `run-context` upon an exit.

boot.janet (1499:1)

## *ffi-context*

keyword

Current native library for ffi/bind and other settings

boot.janet (4318:3)

## *flychecking*

keyword

Check if the current form is being evaluated inside `flycheck`. Will be `true` while flychecking.

boot.janet (173:1)

## *lint-error*

keyword

The current lint error level. The error level is the lint level at which compilation will exit with an error and not continue.

boot.janet (176:1)

## *lint-levels*

keyword

A table of keyword alias to numbers denoting a lint level. Can be used to provided custom aliases for numeric lint levels.

boot.janet (182:1)

## *lint-warn*

keyword

The current lint warning level. The warning level is the lint level at which and error will be printed but compilation will continue as normal.

boot.janet (179:1)

## *macro-form*

keyword

Inside a macro, is bound to the source form that invoked the macro

boot.janet (170:1)

## *macro-lints*

keyword

Bound to an array of lint messages that will be reported by the compiler inside a macro.
To indicate an error or warning, a macro author should use `maclintf`.

boot.janet (185:1)

## *module-cache*

keyword

Dynamic binding for overriding `module/cache`

boot.janet (3156:1)

## *module-loaders*

keyword

Dynamic binding for overriding `module/loaders`

boot.janet (3159:1)

## *module-loading*

keyword

Dynamic binding for overriding `module/loading`

boot.janet (3158:1)

## *module-make-env*

keyword

Dynamic binding for creating new environments for `import`, `require`, and `dofile`. Overrides `make-env`.

boot.janet (3160:1)

## *module-paths*

keyword

Dynamic binding for overriding `module/paths`

boot.janet (3157:1)

## *out*

keyword

Where normal print functions print output to.

boot.janet (1494:1)

## *peg-grammar*

keyword

The implicit base grammar used when compiling PEGs. Any undefined keywords
found when compiling a peg will use lookup in this table (if defined).

boot.janet (2749:1)

## *pretty-format*

keyword

Format specifier for the `pp` function

boot.janet (2168:1)

## *profilepath*

keyword

Path to profile file loaded when starting up the repl.

boot.janet (4962:1)

## *redef*

keyword

When set, allow dynamically rebinding top level defs. Will slow generated code and is intended to be used for development.

boot.janet (1496:1)

## *repl-prompt*

keyword

Allow setting a custom prompt at the default REPL. Not all REPLs will respect this binding.

boot.janet (2171:1)

## *syspath*

keyword

Path of directory to load system modules from.

boot.janet (2795:1)

## *task-id*

keyword

When spawning a thread or fiber, the task-id can be assigned for concurrency control.

boot.janet (1500:1)

## +

function

(+ & xs)
Returns the sum of all xs. If xs is empty, return 0.

## ++

macro

(++ x)
Increments the var x by 1.

boot.janet (138:1)

## +=

macro

(+= x & ns)
Increments the var x by n.

boot.janet (140:1)

## -

function

(- & xs)
Returns the difference of xs. If xs is empty, returns 0. If xs has one element, returns the negative value of that element. Otherwise, returns the first element in xs minus the sum of the rest of the elements.

## --

macro

(-- x)
Decrements the var x by 1.

boot.janet (139:1)

## -=

macro

(-= x & ns)
Decrements the var x by n.

boot.janet (141:1)

## ->

macro

(-> x & forms)
Threading macro. Inserts x as the second value in the first form
in `forms`, and inserts the modified first form into the second form
in the same manner, and so on. Useful for expressing pipelines of data.

boot.janet (1544:1)

## ->>

macro

(->> x & forms)
Threading macro. Inserts x as the last value in the first form
in `forms`, and inserts the modified first form into the second form
in the same manner, and so on. Useful for expressing pipelines of data.

boot.janet (1557:1)

## -?>

macro

(-?> x & forms)
Short circuit threading macro. Inserts x as the second value in the first form
in `forms`, and inserts the modified first form into the second form
in the same manner, and so on. The pipeline will return nil
if an intermediate value is nil.
Useful for expressing pipelines of data.

boot.janet (1570:1)

## -?>>

macro

(-?>> x & forms)
Short circuit threading macro. Inserts x as the last value in the first form
in `forms`, and inserts the modified first form into the second form
in the same manner, and so on. The pipeline will return nil
if an intermediate value is nil.
Useful for expressing pipelines of data.

boot.janet (1586:1)

## /

function

(/ & xs)
Returns the quotient of xs. If xs is empty, returns 1. If xs has one value x, returns the reciprocal of x. Otherwise return the first value of xs repeatedly divided by the remaining values.

## /=

macro

(/= x & ns)
Shorthand for (set x (/ x n)).

boot.janet (143:1)

## <

function

(< & xs)
Check if xs is in ascending order. Returns a boolean.

## <=

function

(<= & xs)
Check if xs is in non-descending order. Returns a boolean.

## =

function

(= & xs)
Check if all values in xs are equal. Returns a boolean.

## >

function

(> & xs)
Check if xs is in descending order. Returns a boolean.

## >=

function

(>= & xs)
Check if xs is in non-ascending order. Returns a boolean.

## abstract?

cfunction

(abstract? x)
Check if x is an abstract type.

../janet/src/core/corelib.c (374:1)

## accumulate

function

(accumulate f init x)
Similar to `reduce`, but accumulates successive results of applying
`f` into a new array. The last element in the array is what would be
the return value from `reduce`. The `init` value is not added
directly as the first value of the new array, i.e. the returned
array will have the same number of elements as `x`.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type
with suitable `get` and `next` methods.

boot.janet (1116:1)

## accumulate2

function

(accumulate2 f x)
The 2-argument version of `accumulate`. Instead of taking an
explicit initial value, the first value of `x` is used instead. If
`x` is empty, returns an empty array.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type
with suitable `get` and `next` methods.

boot.janet (1133:1)

## all

function

(all pred x & xs)
Apply `pred` to values of `x`. Return true if all results are truthy;
if any result is falsey, stop applying `pred` and return the result.
Also functions variadically, i.e. takes additional arguments, with
suitable changes to the arity of `pred`. `pred` is called with both
values from `x` and additional arguments, and only as many times as
the length of the shortest of `x` and each element of `xs`. If `x`
or any element of `xs` is empty, returns true.
`x` and elements of `xs` can be values of type bytes, indexed,
dictionary, fiber, or abstract with suitable `get` and `next`
methods.

boot.janet (2518:1)

## all-bindings

function

(all-bindings &opt env local)
Get all symbols available in an environment. Defaults to the current
fiber's environment. If `local` is truthy, will not show inherited bindings
(from prototype tables).

boot.janet (3564:1)

## all-dynamics

function

(all-dynamics &opt env local)
Get all dynamic bindings in an environment. Defaults to the current
fiber's environment. If `local` is truthy, will not show inherited bindings
(from prototype tables).

boot.janet (3571:1)

## and

macro

(and & forms)
Evaluates to the last argument if all preceding elements are truthy, otherwise
evaluates to the first falsey argument.

boot.janet (305:1)

## any?

function

(any? x)
Evaluates to the last element of `x` if all preceding elements are
falsey, `nil` if `x` is empty, or otherwise to the first truthy
element.
`x` can be a bytes, indexed. dictionary, fiber, or abstract type
with suitable `get` and `next` methods.

boot.janet (1723:1)

## apply

function

(apply f & args)
Applies a function f to a variable number of arguments. Each element in args is used as an argument to f, except the last element in args, which is expected to be an array or a tuple. Each element in this last argument is then also pushed as an argument to f.

## array

cfunction

(array & items)
Create a new array that contains items. Returns the new array.

../janet/src/core/corelib.c (407:1)

## array/clear

cfunction

(array/clear arr)
Empties an array, setting it's count to 0 but does not free the backing capacity. Returns the modified array.

../janet/src/core/array.c (386:1)

## array/concat

cfunction

(array/concat arr & parts)
Concatenates a variable number of arrays (and tuples) into the first argument, which must be an array. If any of the parts are arrays or tuples, their elements will be inserted into the array. Otherwise, each part in `parts` will be appended to `arr` in order. Return the modified array `arr`.

../janet/src/core/array.c (245:1)

## array/ensure

cfunction

(array/ensure arr capacity growth)
Ensures that the memory backing the array is large enough for `capacity` items at the given rate of growth. `capacity` and `growth` must be integers. If the backing capacity is already enough, then this function does nothing. Otherwise, the backing memory will be reallocated so that there is enough space.

../janet/src/core/array.c (214:1)

## array/fill

cfunction

(array/fill arr &opt value)
Replace all elements of an array with `value` (defaulting to nil) without changing the length of the array. Returns the modified array.

../janet/src/core/array.c (169:1)

## array/insert

cfunction

(array/insert arr at & xs)
Insert all `xs` into array `arr` at index `at`. `at` should be an integer between 0 and the length of the array. A negative value for `at` will index backwards from the end of the array, inserting after the index such that inserting at -1 appends to the array. Returns the array.

../janet/src/core/array.c (303:1)

## array/join

cfunction

(array/join arr & parts)
Join a variable number of arrays and tuples into the first argument, which must be an array. Return the modified array `arr`.

../janet/src/core/array.c (278:1)

## array/new

cfunction

(array/new capacity)
Creates a new empty array with a pre-allocated capacity. The same as `(array)` but can be more efficient if the maximum size of an array is known.

../janet/src/core/array.c (136:1)

## array/new-filled

cfunction

(array/new-filled count &opt value)
Creates a new array of `count` elements, all set to `value`, which defaults to nil. Returns the new array.

../janet/src/core/array.c (155:1)

## array/peek

cfunction

(array/peek arr)
Returns the last element of the array. Does not modify the array.

../janet/src/core/array.c (191:1)

## array/pop

cfunction

(array/pop arr)
Remove the last element of the array and return it. If the array is empty, will return nil. Modifies the input array.

../janet/src/core/array.c (182:1)

## array/push

cfunction

(array/push arr & xs)
Push all the elements of xs to the end of an array. Modifies the input array and returns it.

../janet/src/core/array.c (199:1)

## array/remove

cfunction

(array/remove arr at &opt n)
Remove up to `n` elements starting at index `at` in array `arr`. `at` can index from the end of the array with a negative index, and `n` must be a non-negative integer. By default, `n` is 1. Returns the array.

../janet/src/core/array.c (334:1)

## array/slice

cfunction

(array/slice arrtup &opt start end)
Takes a slice of array or tuple from `start` to `end`. The range is half open, [start, end). Indexes can also be negative, indicating indexing from the end of the array. By default, `start` is 0 and `end` is the length of the array. Note that if the range is negative, it is taken as (start, end] to allow a full negative slice range. Returns a new array.

../janet/src/core/array.c (229:1)

## array/trim

cfunction

(array/trim arr)
Set the backing capacity of an array to its current length. Returns the modified array.

../janet/src/core/array.c (364:1)

## array/weak

cfunction

(array/weak capacity)
Creates a new empty array with a pre-allocated capacity and support for weak references. Similar to `array/new`.

../janet/src/core/array.c (146:1)

## array?

function

(array? x)
Check if x is an array.

boot.janet (110:1)

## as->

macro

(as-> x as & forms)
Thread forms together, replacing `as` in `forms` with the value
of the previous form. The first form is the value x. Returns the
last value.

boot.janet (1643:1)

## as-macro

macro

(as-macro f & args)
Use a function or macro literal `f` as a macro. This lets
any function be used as a macro. Inside a quasiquote, the
idiom `(as-macro ,my-custom-macro arg1 arg2...)` can be used
to avoid unwanted variable capture of `my-custom-macro`.

boot.janet (51:1)

## as?->

macro

(as?-> x as & forms)
Thread forms together, replacing `as` in `forms` with the value
of the previous form. The first form is the value x. If any
intermediate values are falsey, return nil; otherwise, returns the
last value.

boot.janet (1655:1)

## asm

cfunction

(asm assembly)
Returns a new function that is the compiled result of the assembly.
The syntax for the assembly can be found on the Janet website, and should correspond
to the return value of disasm. Will throw an
error on invalid assembly.

../janet/src/core/asm.c (1061:1)

## assert

macro

(assert x &opt err)
Throw an error if x is not truthy. Will not evaluate `err` if x is truthy.

boot.janet (146:1)

## assertf

macro

(assertf x fmt & args)
Convenience macro that combines `assert` and `string/format`.

boot.janet (209:1)

## bad-compile

function

(bad-compile msg macrof where &opt line col)
Default handler for a compile error.

boot.janet (2847:1)

## bad-parse

function

(bad-parse p where)
Default handler for a parse error.

boot.janet (2815:1)

## band

function

(band & xs)
Returns the bit-wise and of all values in xs. Each x in xs must be an integer.

## blshift

function

(blshift x & shifts)
Returns the value of x bit shifted left by the sum of all values in shifts. x and each element in shift must be an integer.

## bnot

function

(bnot x)
Returns the bit-wise inverse of integer x.

## boolean?

function

(boolean? x)
Check if x is a boolean.

boot.janet (112:1)

## bor

function

(bor & xs)
Returns the bit-wise or of all values in xs. Each x in xs must be an integer.

## brshift

function

(brshift x & shifts)
Returns the value of x bit shifted right by the sum of all values in shifts. x and each element in shift must be an integer.

## brushift

function

(brushift x & shifts)
Returns the value of x bit shifted right by the sum of all values in shifts. x and each element in shift must be an integer. The sign of x is not preserved, so for positive shifts the return value will always be positive.

## buffer

cfunction

(buffer & xs)
Creates a buffer by concatenating the elements of `xs` together. If an element is not a byte sequence, it is converted to bytes via `describe`. Returns the new buffer.

../janet/src/core/corelib.c (363:1)

## buffer/bit

cfunction

(buffer/bit buffer index)
Gets the bit at the given bit-index. Returns true if the bit is set, false if not.

../janet/src/core/buffer.c (579:1)

## buffer/bit-clear

cfunction

(buffer/bit-clear buffer index)
Clears the bit at the given bit-index. Returns the buffer.

../janet/src/core/buffer.c (568:1)

## buffer/bit-set

cfunction

(buffer/bit-set buffer index)
Sets the bit at the given bit-index. Returns the buffer.

../janet/src/core/buffer.c (557:1)

## buffer/bit-toggle

cfunction

(buffer/bit-toggle buffer index)
Toggles the bit at the given bit index in buffer. Returns the buffer.

../janet/src/core/buffer.c (589:1)

## buffer/blit

cfunction

(buffer/blit dest src &opt dest-start src-start src-end)
Insert the contents of `src` into `dest`. Can optionally take indices that indicate which part of `src` to copy into which part of `dest`. Indices can be negative in order to index from the end of `src` or `dest`. Returns `dest`.

../janet/src/core/buffer.c (600:1)

## buffer/clear

cfunction

(buffer/clear buffer)
Sets the size of a buffer to 0 and empties it. The buffer retains its memory so it can be efficiently refilled. Returns the modified buffer.

../janet/src/core/buffer.c (503:1)

## buffer/fill

cfunction

(buffer/fill buffer &opt byte)
Fill up a buffer with bytes, defaulting to 0s. Does not change the buffer's length. Returns the modified buffer.

../janet/src/core/buffer.c (238:1)

## buffer/format

cfunction

(buffer/format buffer format & args)
Snprintf like functionality for printing values into a buffer. Returns the modified buffer.

../janet/src/core/buffer.c (643:1)

## buffer/format-at

cfunction

(buffer/format-at buffer at format & args)
Snprintf like functionality for printing values into a buffer. Returns the modified buffer.

../janet/src/core/buffer.c (654:1)

## buffer/from-bytes

cfunction

(buffer/from-bytes & byte-vals)
Creates a buffer from integer parameters with byte values. All integers will be coerced to the range of 1 byte 0-255.

../janet/src/core/buffer.c (224:1)

## buffer/new

cfunction

(buffer/new capacity)
Creates a new, empty buffer with enough backing memory for `capacity` bytes. Returns a new buffer of length 0.

../janet/src/core/buffer.c (196:1)

## buffer/new-filled

cfunction

(buffer/new-filled count &opt byte)
Creates a new buffer of length `count` filled with `byte`. By default, `byte` is 0. Returns the new buffer.

../janet/src/core/buffer.c (206:1)

## buffer/popn

cfunction

(buffer/popn buffer n)
Removes the last `n` bytes from the buffer. Returns the modified buffer.

../janet/src/core/buffer.c (513:1)

## buffer/push

cfunction

(buffer/push buffer & xs)
Push both individual bytes and byte sequences to a buffer. For each x in xs, push the byte if x is an integer, otherwise push the bytesequence to the buffer. Thus, this function behaves like both `buffer/push-string` and `buffer/push-byte`. Returns the modified buffer. Expands the buffer as necessary. Throws an error if size limit is exceeded.

../janet/src/core/buffer.c (490:1)

## buffer/push-at

cfunction

(buffer/push-at buffer index & xs)
Same as buffer/push, but copies the new data into the buffer at index `index`.

../janet/src/core/buffer.c (471:1)

## buffer/push-byte

cfunction

(buffer/push-byte buffer & xs)
Append bytes to a buffer. Returns the modified buffer. Expands the buffer as necessary. Throws an error if size limit is exceeded.

../janet/src/core/buffer.c (273:1)

## buffer/push-float32

cfunction

(buffer/push-float32 buffer order data)
Push the underlying bytes of a 32 bit float data onto the end of the buffer. Returns the modified buffer.Expands the buffer as necessary. Throws an error if size limit is exceeded.

../janet/src/core/buffer.c (422:1)

## buffer/push-float64

cfunction

(buffer/push-float64 buffer order data)
Push the underlying bytes of a 64 bit float data onto the end of the buffer. Returns the modified buffer.Expands the buffer as necessary. Throws an error if size limit is exceeded.

../janet/src/core/buffer.c (439:1)

## buffer/push-string

cfunction

(buffer/push-string buffer & xs)
Push byte sequences onto the end of a buffer. Will accept any of strings, keywords, symbols, and buffers. Returns the modified buffer. Expands the buffer as necessary. Throws an error if size limit is exceeded.

../janet/src/core/buffer.c (304:1)

## buffer/push-uint16

cfunction

(buffer/push-uint16 buffer order data)
Push a 16 bit unsigned integer data onto the end of the buffer. Returns the modified buffer.Expands the buffer as necessary. Throws an error if size limit is exceeded.

../janet/src/core/buffer.c (368:1)

## buffer/push-uint32

cfunction

(buffer/push-uint32 buffer order data)
Push a 32 bit unsigned integer data onto the end of the buffer. Returns the modified buffer.Expands the buffer as necessary. Throws an error if size limit is exceeded.

../janet/src/core/buffer.c (388:1)

## buffer/push-uint64

cfunction

(buffer/push-uint64 buffer order data)
Push a 64 bit unsigned integer data onto the end of the buffer. Returns the modified buffer.Expands the buffer as necessary. Throws an error if size limit is exceeded.

../janet/src/core/buffer.c (405:1)

## buffer/push-word

cfunction

(buffer/push-word buffer & xs)
Append machine words to a buffer. The 4 bytes of the integer are appended in twos complement, little endian order, unsigned for all x. Returns the modified buffer. Expands the buffer as necessary. Throws an error if size limit is exceeded.

../janet/src/core/buffer.c (286:1)

## buffer/slice

cfunction

(buffer/slice bytes &opt start end)
Takes a slice of a byte sequence from `start` to `end`. The range is half open, [start, end). Indexes can also be negative, indicating indexing from the end of the end of the array. By default, `start` is 0 and `end` is the length of the buffer. Returns a new buffer.

../janet/src/core/buffer.c (528:1)

## buffer/trim

cfunction

(buffer/trim buffer)
Set the backing capacity of the buffer to the current length of the buffer. Returns the modified buffer.

../janet/src/core/buffer.c (254:1)

## buffer?

function

(buffer? x)
Check if x is a buffer.

boot.janet (105:1)

## bundle/add

function

(bundle/add manifest src &opt dest chmod-mode)
Add a file or directory during an install relative to `(dyn *syspath*)`.
Added files and directories will be recorded in the bundle manifest such
that they are properly tracked and removed during an upgrade or uninstall.

boot.janet (4881:3)

## bundle/add-bin

function

(bundle/add-bin manifest src &opt filename chmod-mode)
Add a file to the "bin" subdirectory of the current syspath. By default,
files will be set to be executable.

boot.janet (4898:3)

## bundle/add-directory

function

(bundle/add-directory manifest dest &opt chmod-mode)
Add a directory during an install relative to `(dyn *syspath*)`.

boot.janet (4836:3)

## bundle/add-file

function

(bundle/add-file manifest src &opt dest chmod-mode)
Add a file during an install relative to `(dyn *syspath*)`.

boot.janet (4864:3)

## bundle/add-manpage

function

(bundle/add-manpage manifest src &opt mansec)
Add a file to the man subdirectory of the current syspath. Files are
copied inside a directory `mansec`. By default, `mansec` is "man1".

boot.janet (4910:3)

## bundle/install

function

(bundle/install path &keys config)
Install a bundle from the local filesystem. The name of the bundle is
the value mapped to :name in either `config` or the info file. There are
5 hooks called during installation (postdeps, clean, build, install and
check). A user can register a hook by defining a function with the same name
in the bundle script.

boot.janet (4693:3)

## bundle/installed?

function

(bundle/installed? bundle-name)
Check if a bundle is installed.

boot.janet (4688:3)

## bundle/list

function

(bundle/list)
Get a list of all installed bundles in lexical order.

boot.janet (4601:3)

## bundle/manifest

function

(bundle/manifest bundle-name)
Get the manifest for a given installed bundle.

boot.janet (4555:3)

## bundle/prune

function

(bundle/prune)
Remove all orphaned bundles from the current syspath. An orphaned bundle is a
bundle that is marked for :auto-remove and is not depended on by any other bundle.

boot.janet (4663:3)

## bundle/reinstall

function

(bundle/reinstall bundle-name &keys new-config)
Reinstall an existing bundle from the local source code.

boot.janet (4828:3)

## bundle/replace

function

(bundle/replace bundle-name path &keys new-config)
Reinstall an existing bundle from a new directory. Similar to
bundle/reinstall, but installs the replacement bundle from any directory.
This is necessary to replace a package without breaking any dependencies.

boot.janet (4807:3)

## bundle/topolist

function

(bundle/topolist)
Get topological order of all bundles, such that each bundle is listed after its dependencies.

boot.janet (4642:3)

## bundle/uninstall

function

(bundle/uninstall bundle-name)
Remove a bundle from the current syspath. There is 1 hook called during
uninstallation (uninstall). A user can register a hook by defining a
function with the same name in the bundle script.

boot.janet (4625:3)

## bundle/update-all

function

(bundle/update-all &keys configs)
Reinstall all bundles.

boot.janet (4922:3)

## bundle/whois

function

(bundle/whois path)
Given a file path, figure out which bundle installed it.

boot.janet (4851:3)

## bxor

function

(bxor & xs)
Returns the bit-wise xor of all values in xs. Each x in xs must be an integer.

## bytes?

cfunction

(bytes? x)
Check if x is a string, symbol, keyword, or buffer.

../janet/src/core/corelib.c (677:1)

## cancel

function

(cancel fiber err)
Resume a fiber but have it immediately raise an error. This lets a programmer unwind a pending fiber. Returns the same result as resume.

## case

macro

(case dispatch & pairs)
Select the body that equals the dispatch value. When `pairs`
has an odd number of elements, the last is the default expression.
If no match is found, returns nil.

boot.janet (259:1)

## catseq

macro

(catseq head & body)
Similar to `loop`, but concatenates each element from the loop body into an array and returns that.
See `loop` for details.

boot.janet (740:1)

## cfunction?

function

(cfunction? x)
Check if x is a cfunction.

boot.janet (107:1)

## chr

macro

(chr c)
Convert a string of length 1 to its byte (ascii) value at compile time.

boot.janet (415:1)

## cli-main

function

(cli-main args)
Entrance for the Janet CLI tool. Call this function with the command line
arguments as an array or tuple of strings to invoke the CLI interface.

boot.janet (5008:1)

## cmp

function

(cmp x y)
Returns -1 if x is strictly less than y, 1 if y is strictly greater than x, and 0 otherwise. To return 0, x and y must be the exact same type.

## comment

macro

(comment &)
Ignores the body of the comment.

boot.janet (225:1)

## comp

function

(comp & functions)
Takes multiple functions and returns a function that is the composition
of those functions.

boot.janet (836:1)

## compare

function

(compare x y)
Polymorphic compare. Returns -1, 0, 1 for x < y, x = y, x > y respectively.
Differs from the primitive comparators in that it first checks to
see whether either x or y implement a `compare` method which can
compare x and y. If so, it uses that method. If not, it
delegates to the primitive comparators.

boot.janet (941:1)

## compare<

function

(compare< & xs)
Equivalent of `<` but using polymorphic `compare` instead of primitive comparator.

boot.janet (966:1)

## compare<=

function

(compare<= & xs)
Equivalent of `<=` but using polymorphic `compare` instead of primitive comparator.

boot.janet (971:1)

## compare=

function

(compare= & xs)
Equivalent of `=` but using polymorphic `compare` instead of primitive comparator.

boot.janet (961:1)

## compare>

function

(compare> & xs)
Equivalent of `>` but using polymorphic `compare` instead of primitive comparator.

boot.janet (976:1)

## compare>=

function

(compare>= & xs)
Equivalent of `>=` but using polymorphic `compare` instead of primitive comparator.

boot.janet (981:1)

## compif

macro

(compif cnd tru &opt fals)
Check the condition `cnd` at compile time -- if truthy, compile `tru`, else compile `fals`.

boot.janet (3125:1)

## compile

cfunction

(compile ast &opt env source lints)
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. If a `lints` array is given, linting messages will be appended to the array. Each message will be a tuple of the form `(level line col message)`.

../janet/src/core/compile.c (1208:1)

## complement

function

(complement f)
Returns a function that is the complement to the argument.

boot.janet (855:1)

## comptime

macro

(comptime x)
Evals x at compile time and returns the result. Similar to a top level unquote.

boot.janet (3119:1)

## compwhen

macro

(compwhen cnd & body)
Check the condition `cnd` at compile time -- if truthy, compile `(upscope ;body)`, else compile nil.

boot.janet (3132:1)

## cond

macro

(cond & pairs)
Evaluates conditions sequentially until the first true condition
is found, and then executes the corresponding body. If there are an
odd number of forms, and no forms are matched, the last expression
is executed. If there are no matches, returns nil.

boot.janet (244:1)

## coro

macro

(coro & body)
A wrapper for making fibers that may yield multiple values (coroutine). Same as `(fiber/new (fn [] ;body) :yi)`.

boot.janet (762:1)

## count

function

(count pred x & xs)
Count the number of values in `x` for which applying `pred` yields a
truthy value.
Also functions variadically, i.e. takes additional arguments, with
suitable changes to the arity of `pred`. `pred` is called with both
values from `x` and additional arguments, and only as many times as
the length of the shortest of `x` and each element of `xs`. If `x`
or any element of `xs` is empty, returns 0.
`x` and elements of `xs` can be values of type bytes, indexed,
dictionary, fiber, or abstract with suitable `get` and `next`
methods.

boot.janet (1256:1)

## curenv

function

(curenv &opt n)
Get the current environment table. Same as `(fiber/getenv (fiber/current))`. If `n`
is provided, gets the nth prototype of the environment table.

boot.janet (2864:1)

## debug

function

(debug &opt x)
Throws a debug signal that can be caught by a parent fiber and used to inspect the running state of the current fiber. Returns the value passed in by resume.

## debug/arg-stack

cfunction

(debug/arg-stack fiber)
Gets all values currently on the fiber's argument stack. Normally, this should be empty unless the fiber signals while pushing arguments to make a function call. Returns a new array.

../janet/src/core/debug.c (417:1)

## debug/break

cfunction

(debug/break source line col)
Sets a breakpoint in `source` at a given line and column. Will throw an error if the breakpoint location cannot be found. For example
(debug/break "core.janet" 10 4)
will set a breakpoint at line 10, 4th column of the file core.janet.

../janet/src/core/debug.c (220:1)

## debug/fbreak

cfunction

(debug/fbreak fun &opt pc)
Set a breakpoint in a given function. pc is an optional offset, which is in bytecode instructions. fun is a function value. Will throw an error if the offset is too large or negative.

../janet/src/core/debug.c (246:1)

## debug/lineage

cfunction

(debug/lineage fib)
Returns an array of all child fibers from a root fiber. This function is useful when a fiber signals or errors to an ancestor fiber. Using this function, the fiber handling the error can see which fiber raised the signal. This function should be used mostly for debugging purposes.

../janet/src/core/debug.c (268:1)

## debug/stack

cfunction

(debug/stack fib)
Gets information about the stack as an array of tables. Each table in the array contains information about a stack frame. The top-most, current stack frame is the first table in the array, and the bottom-most stack frame is the last value. Each stack frame contains some of the following attributes:
* :c - true if the stack frame is a c function invocation
* :source-column - the current source column of the stack frame
* :function - the function that the stack frame represents
* :source-line - the current source line of the stack frame
* :name - the human-friendly name of the function
* :pc - integer indicating the location of the program counter
* :source - string with the file path or other identifier for the source code
* :slots - array of all values in each slot
* :tail - boolean indicating a tail call

../janet/src/core/debug.c (374:1)

## debug/stacktrace

cfunction

(debug/stacktrace fiber &opt err prefix)
Prints a nice looking stacktrace for a fiber. Can optionally provide an error value to print the stack trace with. If `prefix` is nil or not provided, will skip the error line. Returns the fiber.

../janet/src/core/debug.c (404:1)

## debug/step

cfunction

(debug/step fiber &opt x)
Run a fiber for one virtual instruction of the Janet machine. Can optionally pass in a value that will be passed as the resuming value. Returns the signal value, which will usually be nil, as breakpoints raise nil signals.

../janet/src/core/debug.c (432:1)

## debug/unbreak

cfunction

(debug/unbreak source line column)
Remove a breakpoint with a source key at a given line and column. Will throw an error if the breakpoint cannot be found.

../janet/src/core/debug.c (234:1)

## debug/unfbreak

cfunction

(debug/unfbreak fun &opt pc)
Unset a breakpoint set with debug/fbreak.

../janet/src/core/debug.c (258:1)

## debugger

function

(debugger fiber &opt level)
Run a repl-based debugger on a fiber. Optionally pass in a level to differentiate nested debuggers.

boot.janet (3326:1)

## debugger-env

table

An environment that contains dot prefixed functions for debugging.

boot.janet (3320:1)

## debugger-on-status

function

(debugger-on-status env &opt level is-repl)
Create a function that can be passed to `run-context`'s `:on-status` argument that will drop into a debugger on errors. The debugger will only start on abnormal signals if the env table has the `:debug` dyn set to a truthy value.

boot.janet (3352:1)

## dec

function

(dec x)
Returns x - 1.

boot.janet (137:1)

## deep-not=

function

(deep-not= x y)
Like `not=`, but mutable types (arrays, tables, buffers) are considered
equal if they have identical structure. Much slower than `not=`.

boot.janet (2614:1)

## deep=

function

(deep= x y)
Like `=`, but mutable types (arrays, tables, buffers) are considered
equal if they have identical structure. Much slower than `=`.

boot.janet (2643:1)

## def-

macro

(def- name & more)
Define a private value that will not be exported.

boot.janet (69:1)

## default

macro

(default sym val)
Define a default value for an optional argument.
Expands to `(def sym :shadow (if (= nil sym) val sym))`.

boot.janet (219:1)

## default-peg-grammar

table

The default grammar used for pegs. This grammar defines several common patterns
that should make it easier to write more complex patterns.

boot.janet (2753:1)

## defdyn

macro

(defdyn alias & more)
Define an alias for a keyword that is used as a dynamic binding. The
alias is a normal, lexically scoped binding that can be used instead of
a keyword to prevent typos. `defdyn` does not set dynamic bindings or otherwise
replace `dyn` and `setdyn`. The alias *must* start and end with the `*` character, usually
called "earmuffs".

boot.janet (156:1)

## defer

macro

(defer form & body)
Run `form` unconditionally after `body`, even if the body throws an error.
Will also run `form` if a user signal 0-4 is received.

boot.janet (384:1)

## defglobal

function

(defglobal name value)
Dynamically create a global def.

boot.janet (84:1)

## defmacro

macro

(defmacro name & more)
Define a macro.

boot.janet (46:1)

## defmacro-

macro

(defmacro- name & more)
Define a private macro that will not be exported.

boot.janet (59:1)

## defn

macro

(defn name & more)
Define a function. Equivalent to `(def name (fn name [args] ...))`.

boot.janet (10:1)

## defn-

macro

(defn- name & more)
Define a private function that will not be exported.

boot.janet (64:1)

## delay

macro

(delay & forms)
Lazily evaluate a series of expressions. Returns a function that returns the result of the last expression. Will only evaluate the body once, and then memoizes the result.

boot.janet (4299:1)

## describe

cfunction

(describe x)
Returns a string that is a human-readable description of `x`. For indexed, dictionary, fiber, pointer, and some abstract types, the string returned contains a pointer value from which the identity of `x` can be determined.

../janet/src/core/corelib.c (318:1)

## dictionary?

cfunction

(dictionary? x)
Check if x is a table or struct.

../janet/src/core/corelib.c (691:1)

## disasm

cfunction

(disasm func &opt field)
Returns assembly that could be used to compile the given function. func must be a function, not a c function. Will throw on error on a badly typed argument. If given a field name, will only return that part of the function assembly. Possible fields are:
* :arity - number of required and optional arguments.
* :min-arity - minimum number of arguments function can be called with.
* :max-arity - maximum number of arguments function can be called with.
* :vararg - true if function can take a variable number of arguments.
* :structarg - true if function can take a variable number of arguments using the &keys option.
* :namedargs - if function can take a variable number of arguments using the &named option, this will be the number of named arguments.
* :bytecode - array of parsed bytecode instructions. Each instruction is a tuple.
* :source - name of source file that this function was compiled from.
* :name - name of function.
* :slotcount - how many virtual registers, or slots, this function uses. Corresponds to stack space used by function.
* :symbolmap - all symbols and their slots.
* :constants - an array of constants referenced by this function.
* :sourcemap - a mapping of each bytecode instruction to a line and column in the source file.
* :environments - an internal mapping of which enclosing functions are referenced for bindings.
* :defs - other function definitions that this function may instantiate.

../janet/src/core/asm.c (1077:1)

## distinct

function

(distinct xs)
Returns an array of the deduplicated values in `xs`.

boot.janet (2042:1)

## div

function

(div & xs)
Returns the floored division of xs. If xs is empty, returns 1. If xs has one value x, returns the reciprocal of x. Otherwise return the first value of xs repeatedly divided by the remaining values.

## doc

macro

(doc &opt sym)
Shows documentation for the given symbol, or can show a list of available bindings.
If `sym` is a symbol, will look for documentation for that symbol. If `sym` is a string
or is not provided, will show all lexical and dynamic bindings in the current environment
containing that string (all bindings will be shown if no string is given).

boot.janet (3915:1)

## doc*

function

(doc* &opt sym)
Get the documentation for a symbol in a given environment. Function form of `doc`.

boot.janet (3887:1)

## doc-format

function

(doc-format str &opt width indent colorize)
Reformat a docstring to wrap a certain width. Docstrings can either be plaintext
or a subset of markdown. This allows a long single line of prose or formatted text to be
a well-formed docstring. Returns a buffer containing the formatted text.

boot.janet (3584:1)

## doc-of

function

(doc-of x)
Searches all loaded modules in module/cache for a given binding and prints out its documentation.
This does a search by value instead of by name. Returns nil.

boot.janet (3923:1)

## dofile

function

(dofile path &named exit env source expander evaluator read parser)
Evaluate a file, file path, or stream and return the resulting environment. :env, :expander,
:source, :evaluator, :read, and :parser are passed through to the underlying
`run-context` call. If `exit` is true, any top level errors will trigger a
call to `(os/exit 1)` after printing the error.

boot.janet (3378:1)

## drop

function

(drop n ind)
Drop the first `n` elements in an indexed or bytes type. Returns a new tuple or string
instance, respectively. If `n` is negative, drops the last `n` elements instead.

boot.janet (1409:1)

## drop-until

function

(drop-until pred ind)
Same as `(drop-while (complement pred) ind)`.

boot.janet (1437:1)

## drop-while

function

(drop-while pred ind)
Given a predicate, remove elements from an indexed or bytes type that satisfy
the predicate, and abort on first failure. Returns a new tuple or string, respectively.

boot.janet (1447:1)

## dyn

cfunction

(dyn key &opt default)
Get a dynamic binding. Returns the default value (or nil) if no binding found.

../janet/src/core/corelib.c (262:1)

## each

macro

(each binding x & body)
Loop over each value in `x` with each value of `x` bound to
`binding` with destructuring support. Returns `nil`.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type
with suitable `get` and `next` methods.

boot.janet (622:1)

## eachk

macro

(eachk binding x & body)
Loop over each key in `x` with each key bound to `binding` with
destructuring support. Returns `nil`.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type
with a suitable `next` method.

boot.janet (600:1)

## eachp

macro

(eachp binding x & body)
Loop over each (key, value) pair in `x` with each pair bound to
`binding` with destructuring support. Returns `nil`.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type
with suitable `get` and `next` methods.

boot.janet (611:1)

## edefer

macro

(edefer form & body)
Run `form` after `body` in the case that body terminates abnormally (an error or user signal 0-4).
Otherwise, return last form in `body`.

boot.janet (390:1)

## eflush

cfunction

(eflush)
Flush `(dyn :err stderr)` if it is a file, otherwise do nothing.

../janet/src/core/io.c (735:1)

## empty?

function

(empty? iter)
Check if an iterable, `iter`, is empty.

boot.janet (117:1)

## env-lookup

cfunction

(env-lookup env)
Creates a forward lookup table for unmarshalling from an environment. To create a reverse lookup table, use the invert function to swap keys and values in the returned table.

../janet/src/core/marsh.c (1671:1)

## eprin

cfunction

(eprin & xs)
Same as `prin`, but uses `(dyn :err stderr)` instead of `(dyn :out stdout)`.

../janet/src/core/io.c (582:1)

## eprinf

cfunction

(eprinf fmt & xs)
Like `eprintf` but with no trailing newline.

../janet/src/core/io.c (688:1)

## eprint

cfunction

(eprint & xs)
Same as `print`, but uses `(dyn :err stderr)` instead of `(dyn :out stdout)`.

../janet/src/core/io.c (576:1)

## eprintf

cfunction

(eprintf fmt & xs)
Prints output formatted as if with `(string/format fmt ;xs)` to `(dyn :err stderr)` with a trailing newline.

../janet/src/core/io.c (682:1)

## error

function

(error e)
Throws an error e that can be caught and handled by a parent fiber.

## errorf

function

(errorf fmt & args)
A combination of `error` and `string/format`. Equivalent to `(error (string/format fmt ;args))`.

boot.janet (204:1)

## ev/acquire-lock

cfunction

(ev/acquire-lock lock)
Acquire a lock such that this operating system thread is the only thread with access to this resource. This will block this entire thread until the lock becomes available, and will not yield to other fibers on this system thread.

../janet/src/core/ev.c (3488:1)

## ev/acquire-rlock

cfunction

(ev/acquire-rlock rwlock)
Acquire a read lock an a read-write lock.

../janet/src/core/ev.c (3530:1)

## ev/acquire-wlock

cfunction

(ev/acquire-wlock rwlock)
Acquire a write lock on a read-write lock.

../janet/src/core/ev.c (3539:1)

## ev/all-tasks

cfunction

(ev/all-tasks)
Get an array of all active task fibers that are being used by the scheduler.

../janet/src/core/ev.c (3625:1)

## ev/call

function

(ev/call f & args)
Call a function asynchronously.
Returns a task fiber that is scheduled to run the function.

boot.janet (4165:3)

## ev/cancel

cfunction

(ev/cancel fiber err)
Cancel a suspended task fiber in the event loop. Differs from `cancel` in that it returns the canceled fiber immediately.

../janet/src/core/ev.c (3390:1)

## ev/capacity

cfunction

(ev/capacity channel)
Get the number of items a channel will store before blocking writers.

../janet/src/core/ev.c (1291:1)

## ev/chan

cfunction

(ev/chan &opt capacity)
Create a new channel. capacity is the number of values to queue before blocking writers, defaults to 0 if not provided. Returns a new channel.

../janet/src/core/ev.c (1330:1)

## ev/chan-close

cfunction

(ev/chan-close chan)
Close a channel. A closed channel will cause all pending reads and writes to return nil. Returns the channel.

../janet/src/core/ev.c (1352:1)

## ev/chunk

cfunction

(ev/chunk stream n &opt buffer timeout)
Same as ev/read, but will not return early if less than n bytes are available. If an end of stream is reached, will also return early with the collected bytes.

../janet/src/core/ev.c (3433:1)

## ev/close

cfunction

(ev/close stream)
Close a stream. This should be the same as calling (:close stream) for all streams.

../janet/src/core/ev.c (3401:1)

## ev/count

cfunction

(ev/count channel)
Get the number of items currently waiting in a channel.

../janet/src/core/ev.c (1302:1)

## ev/deadline

cfunction

(ev/deadline sec &opt tocancel tocheck intr?)
Schedules the event loop to try to cancel the `tocancel` task as with `ev/cancel`. After `sec` seconds, the event loop will attempt cancellation of `tocancel` if the `tocheck` fiber is resumable. `sec` is a number that can have a fractional part. `tocancel` defaults to `(fiber/root)`, but if specified, must be a task (root fiber). `tocheck` defaults to `(fiber/current)`, but if specified, must be a fiber. Returns `tocancel` immediately. If `interrupt?` is set to true, will create a background thread to try to interrupt the VM if the timeout expires.

../janet/src/core/ev.c (3325:1)

## ev/do-thread

macro

(ev/do-thread & body)
Run some code in a new thread. Suspends the current fiber until the thread is complete, and
evaluates to nil.

boot.janet (4181:3)

## ev/full

cfunction

(ev/full channel)
Check if a channel is full or not.

../janet/src/core/ev.c (1280:1)

## ev/gather

macro

(ev/gather & bodies)
Create and run a number of fibers in parallel (created from `bodies`) and resume the
current fiber after they complete. Shorthand for `ev/go-gather`. Returns the gathered results in an
array.

boot.janet (4269:3)

## ev/give

cfunction

(ev/give channel value)
Write a value to a channel, suspending the current fiber if the channel is full. Returns the channel if the write succeeded, nil otherwise.

../janet/src/core/ev.c (1179:1)

## ev/give-supervisor

cfunction

(ev/give-supervisor tag & payload)
Send a message to the current supervisor channel if there is one. The message will be a tuple of all of the arguments combined into a single message, where the first element is tag. By convention, tag should be a keyword indicating the type of message. Returns nil.

../janet/src/core/ev.c (3289:1)

## ev/go

cfunction

(ev/go fiber-or-fun &opt value supervisor)
Put a fiber on the event loop to be resumed later. If a function is used, it is wrapped with `fiber/new` first. Returns a task fiber. Optionally pass a value to resume with, otherwise resumes with nil. An optional `core/channel` can be provided as a supervisor. When various events occur in the newly scheduled fiber, an event will be pushed to the supervisor. If not provided, the new fiber will inherit the current supervisor.

../janet/src/core/ev.c (3061:1)

## ev/go-gather

function

(ev/go-gather thunks)
Run a dyanmic number of fibers in parallel and resume the current fiber after they complete. Takes
an array of functions or fibers, `thunks`, that will be run via `ev/go` in another task.
Returns the gathered results in an array.

boot.janet (4250:3)

## ev/lock

cfunction

(ev/lock)
Create a new lock to coordinate threads.

../janet/src/core/ev.c (3478:1)

## ev/read

cfunction

(ev/read stream n &opt buffer timeout)
Read up to n bytes into a buffer asynchronously from a stream. `n` can also be the keyword `:all` to read into the buffer until end of stream. Optionally provide a buffer to write into as well as a timeout in seconds after which to cancel the operation and raise an error. Returns the buffer if the read was successful or nil if end-of-stream reached. Will raise an error if there are problems with the IO operation.

../janet/src/core/ev.c (3410:1)

## ev/release-lock

cfunction

(ev/release-lock lock)
Release a lock such that other threads may acquire it.

../janet/src/core/ev.c (3499:1)

## ev/release-rlock

cfunction

(ev/release-rlock rwlock)
Release a read lock on a read-write lock

../janet/src/core/ev.c (3548:1)

## ev/release-wlock

cfunction

(ev/release-wlock rwlock)
Release a write lock on a read-write lock

../janet/src/core/ev.c (3557:1)

## ev/rselect

cfunction

(ev/rselect & clauses)
Similar to ev/select, but will try clauses in a random order for fairness.

../janet/src/core/ev.c (1323:1)

## ev/rwlock

cfunction

(ev/rwlock)
Create a new read-write lock to coordinate threads.

../janet/src/core/ev.c (3520:1)

## ev/select

cfunction

(ev/select & clauses)
Block until the first of several channel operations occur. Returns a tuple of the form [:give chan], [:take chan x], or [:close chan], where a :give tuple is the result of a write and a :take tuple is the result of a read. Each clause must be either a channel (for a channel take operation) or a tuple [channel x] (for a channel give operation). Operations are tried in order such that earlier clauses take precedence over later clauses. Both give and take operations can return a [:close chan] tuple, which indicates that the specified channel was closed while waiting, or that the channel was already closed.

../janet/src/core/ev.c (1209:1)

## ev/sleep

cfunction

(ev/sleep sec)
Suspend the current fiber for sec seconds without blocking the event loop.

../janet/src/core/ev.c (3317:1)

## ev/spawn

macro

(ev/spawn & body)
Run some code in a new task fiber. This is shorthand for
`(ev/go (fn [] ;body))`."

boot.janet (4173:3)

## ev/spawn-thread

macro

(ev/spawn-thread & body)
Run some code in a new thread. Like `ev/do-thread`, but returns nil immediately.

boot.janet (4211:3)

## ev/take

cfunction

(ev/take channel)
Read from a channel, suspending the current fiber if no value is available.

../janet/src/core/ev.c (1194:1)

## ev/thread

cfunction

(ev/thread main &opt value flags supervisor)
Run `main` in a new operating system thread, optionally passing `value` to resume with. The parameter `main` can either be a fiber, or a function that accepts 0 or 1 arguments. Unlike `ev/go`, this function will suspend the current fiber until the thread is complete. If you want to run the thread without waiting for a result, pass the `:n` flag to return nil immediately. Otherwise, returns nil. Available flags:
* `:n` - return immediately
* `:t` - set the task-id of the new thread to value. The task-id is passed in messages to the supervisor channel.
* `:a` - don't copy abstract registry to new thread (performance optimization)
* `:c` - don't copy cfunction registry to new thread (performance optimization)

../janet/src/core/ev.c (3224:1)

## ev/thread-chan

cfunction

(ev/thread-chan &opt limit)
Create a threaded channel. A threaded channel is a channel that can be shared between threads and used to communicate between any number of operating system threads.

../janet/src/core/ev.c (1341:1)

## ev/to-file

cfunction

(ev/to-file)
Create core/file copy of the stream. This value can be used when blocking IO behavior is needed.

../janet/src/core/ev.c (3614:1)

## ev/with-deadline

macro

(ev/with-deadline sec & body)
Create a fiber to execute `body`, schedule the event loop to cancel
the task (root fiber) associated with `body`'s fiber, and start
`body`'s fiber by resuming it.
The event loop will try to cancel the root fiber if `body`'s fiber
has not completed after at least `sec` seconds.
`sec` is a number that can have a fractional part.

boot.janet (4216:3)

## ev/with-lock

macro

(ev/with-lock lock & body)
Run a body of code after acquiring a lock. Will automatically release the lock when done.

boot.janet (4196:3)

## ev/with-rlock

macro

(ev/with-rlock lock & body)
Run a body of code after acquiring read access to an rwlock. Will automatically release the lock when done.

boot.janet (4201:3)

## ev/with-wlock

macro

(ev/with-wlock lock & body)
Run a body of code after acquiring write access to an rwlock. Will automatically release the lock when done.

boot.janet (4206:3)

## ev/write

cfunction

(ev/write stream data &opt timeout)
Write data to a stream, suspending the current fiber until the write completes. Takes an optional timeout in seconds, after which will return nil. Returns nil, or raises an error if the write failed.

../janet/src/core/ev.c (3447:1)

## eval

function

(eval form &opt env)
Evaluates a form in the current environment. If more control over the
environment is needed, use `run-context`. Optionally pass in an `env` table with available bindings.

boot.janet (3061:1)

## eval-string

function

(eval-string str &opt env)
Evaluates a string in the current environment. If more control over the
environment is needed, use `run-context`. Optionally pass in an `env` table with available bindings.

boot.janet (3101:1)

## even?

function

(even? x)
Check if x is even.

boot.janet (990:1)

## every?

function

(every? x)
Evaluates to the last element of `x` if all preceding elements are
truthy, true if `x` is empty, or otherwise to the first falsey
element.
`x` can be a bytes, indexed. dictionary, fiber, or abstract type
with suitable `get` and `next` methods.

boot.janet (1708:1)

## extreme

function

(extreme order args)
Returns the most extreme value in `args` based on the function `order`.
`order` should take two values and return true or false (a comparison).
Returns nil if `args` is empty.

boot.janet (871:1)

## false?

function

(false? x)
Check if x is false.

boot.janet (115:1)

## ffi/align

cfunction

(ffi/align type)
Get the align of an ffi type in bytes.

../janet/src/core/ffi.c (484:1)

## ffi/call

cfunction

(ffi/call pointer signature & args)
Call a raw pointer as a function pointer. The function signature specifies how Janet values in `args` are converted to native machine types.

../janet/src/core/ffi.c (1668:1)

## ffi/calling-conventions

cfunction

(ffi/calling-conventions)
Get an array of all supported calling conventions on the current architecture. Some architectures may have some FFI functionality (ffi/malloc, ffi/free, ffi/read, ffi/write, etc.) but not support any calling conventions. This function can be used to get all supported calling conventions that can be used on this architecture. All architectures support the :none calling convention which is a placeholder that cannot be used at runtime.

../janet/src/core/ffi.c (1870:1)

## ffi/close

cfunction

(ffi/close native)
Free a native object. Dereferencing pointers to symbols in the object will have undefined behavior after freeing.

../janet/src/core/ffi.c (1802:1)

## ffi/context

function

(ffi/context &opt native-path &named map-symbols lazy)
Set the path of the dynamic library to implicitly bind, as well as other global state for ease of creating native bindings.

boot.janet (4324:3)

## ffi/defbind

macro

(ffi/defbind name ret-type & body)
Generate bindings for native functions in a convenient manner.

boot.janet (4366:3)

## ffi/defbind-alias

macro

(ffi/defbind-alias name alias ret-type & body)
Generate bindings for native functions in a convenient manner. Similar to defbind but allows for the janet function name to be different than the FFI function.

boot.janet (4338:3)

## ffi/free

cfunction

(ffi/free pointer)
Free memory allocated with `ffi/malloc`. Returns nil.

../janet/src/core/ffi.c (1826:1)

## ffi/jitfn

cfunction

(ffi/jitfn bytes)
Create an abstract type that can be used as the pointer argument to `ffi/call`. The content of `bytes` is architecture specific machine code that will be copied into executable memory.

../janet/src/core/ffi.c (1610:1)

## ffi/lookup

cfunction

(ffi/lookup native symbol-name)
Lookup a symbol from a native object. All symbol lookups will return a raw pointer if the symbol is found, else nil.

../janet/src/core/ffi.c (1788:1)

## ffi/malloc

cfunction

(ffi/malloc size)
Allocates memory directly using the janet memory allocator. Memory allocated in this way must be freed manually! Returns a raw pointer, or nil if size = 0.

../janet/src/core/ffi.c (1816:1)

## ffi/native

cfunction

(ffi/native &opt path)
Load a shared object or dll from the given path, and do not extract or run any code from it. This is different than `native`, which will run initialization code to get a module table. If `path` is nil, opens the current running binary. Returns a `core/native`.

../janet/src/core/ffi.c (1770:1)

## ffi/pointer-buffer

cfunction

(ffi/pointer-buffer pointer capacity &opt count offset)
Create a buffer from a pointer. The underlying memory of the buffer will not be reallocated or freed by the garbage collector, allowing unmanaged, mutable memory to be manipulated with buffer functions. Attempts to resize or extend the buffer beyond its initial capacity will raise an error. As with many FFI functions, this is memory unsafe and can potentially allow out of bounds memory access. Returns a new buffer.

../janet/src/core/ffi.c (1837:1)

## ffi/pointer-cfunction

cfunction

(ffi/pointer-cfunction pointer &opt name source-file source-line)
Create a C Function from a raw pointer. Optionally give the cfunction a name and source location for stack traces and debugging.

../janet/src/core/ffi.c (1854:1)

## ffi/read

cfunction

(ffi/read ffi-type bytes &opt offset)
Parse a native struct out of a buffer and convert it to normal Janet data structures. This function is the inverse of `ffi/write`. `bytes` can also be a raw pointer, although this is unsafe.

../janet/src/core/ffi.c (1720:1)

## ffi/signature

cfunction

(ffi/signature calling-convention ret-type & arg-types)
Create a function signature object that can be used to make calls with raw function pointers.

../janet/src/core/ffi.c (878:1)

## ffi/size

cfunction

(ffi/size type)
Get the size of an ffi type in bytes.

../janet/src/core/ffi.c (476:1)

## ffi/struct

cfunction

(ffi/struct & types)
Create a struct type definition that can be used to pass structs into native functions.

../janet/src/core/ffi.c (469:1)

## ffi/trampoline

cfunction

(ffi/trampoline cc)
Get a native function pointer that can be used as a callback and passed to C libraries. This callback trampoline has the signature `void trampoline(void \*ctx, void \*userdata)` in the given calling convention. This is the only function signature supported. It is up to the programmer to ensure that the `userdata` argument contains a janet function the will be called with one argument, `ctx` which is an opaque pointer. This pointer can be further inspected with `ffi/read`.

../janet/src/core/ffi.c (1740:1)

## ffi/write

cfunction

(ffi/write ffi-type data &opt buffer index)
Append a native type to a buffer such as it would appear in memory. This can be used to pass pointers to structs in the ffi, or send C/C++/native structs over the network or to files. Returns a modified buffer or a new buffer if one is not supplied.

../janet/src/core/ffi.c (1697:1)

## fiber-fn

macro

(fiber-fn flags & body)
A wrapper for making fibers. Same as `(fiber/new (fn [] ;body) flags)`.

boot.janet (767:1)

## fiber/can-resume?

cfunction

(fiber/can-resume? fiber)
Check if a fiber is finished and cannot be resumed.

../janet/src/core/fiber.c (656:1)

## fiber/current

cfunction

(fiber/current)
Returns the currently running fiber.

../janet/src/core/fiber.c (602:1)

## fiber/getenv

cfunction

(fiber/getenv fiber)
Gets the environment for a fiber. Returns nil if no such table is set yet.

../janet/src/core/fiber.c (455:1)

## fiber/last-value

cfunction

(fiber/last-value fiber)
Get the last value returned or signaled from the fiber.

../janet/src/core/fiber.c (664:1)

## fiber/maxstack

cfunction

(fiber/maxstack fib)
Gets the maximum stack size in janet values allowed for a fiber. While memory for the fiber's stack is not allocated up front, the fiber will not allocated more than this amount and will throw a stack-overflow error if more memory is needed.

../janet/src/core/fiber.c (620:1)

## fiber/new

cfunction

(fiber/new func &opt sigmask env)
Create a new fiber with function body func. Can optionally take a set of signals `sigmask` to capture from child fibers, and an environment table `env`. The mask is specified as a keyword where each character is used to indicate a signal to block. If the ev module is enabled, and this fiber is used as an argument to `ev/go`, these "blocked" signals will result in messages being sent to the supervisor channel. The default sigmask is :y. For example,
(fiber/new myfun :e123)
blocks error signals and user signals 1, 2 and 3. The signals are as follows:
* :a - block all signals
* :d - block debug signals
* :e - block error signals
* :t - block termination signals: error + user[0-4]
* :u - block user signals
* :y - block yield signals
* :w - block await signals (user9)
* :r - block interrupt signals (user8)
* :0-9 - block a specific user signal
The sigmask argument also can take environment flags. If any mutually exclusive flags are present, the last flag takes precedence.
* :i - inherit the environment from the current fiber
* :p - the environment table's prototype is the current environment table

../janet/src/core/fiber.c (480:1)

## fiber/root

cfunction

(fiber/root)
Returns the current root fiber. The root fiber is the oldest ancestor that does not have a parent. Note that a root fiber is also a task fiber.

../janet/src/core/fiber.c (610:1)

## fiber/setenv

cfunction

(fiber/setenv fiber table)
Sets the environment table for a fiber. Set to nil to remove the current environment.

../janet/src/core/fiber.c (466:1)

## fiber/setmaxstack

cfunction

(fiber/setmaxstack fib maxstack)
Sets the maximum stack size in janet values for a fiber. By default, the maximum stack size is usually 8192.

../janet/src/core/fiber.c (630:1)

## fiber/status

cfunction

(fiber/status fib)
Get the status of a fiber. The status will be one of:
* :dead - the fiber has finished
* :error - the fiber has errored out
* :debug - the fiber is suspended in debug mode
* :pending - the fiber has been yielded
* :user(0-7) - the fiber is suspended by a user signal
* :interrupted - the fiber was interrupted
* :suspended - the fiber is waiting to be resumed by the scheduler
* :new - the fiber has just been created and not yet run
* :alive - the fiber is currently running and cannot be resumed

../janet/src/core/fiber.c (584:1)

## fiber?

function

(fiber? x)
Check if x is a fiber.

boot.janet (101:1)

## file/close

cfunction

(file/close f)
Close a file and release all related resources. When you are done reading a file, close it to prevent a resource leak and let other processes read the file.

../janet/src/core/io.c (324:1)

## file/flush

cfunction

(file/flush f)
Flush any buffered bytes to the file system. In most files, writes are buffered for efficiency reasons. Returns the file handle.

../janet/src/core/io.c (287:1)

## file/lines

function

(file/lines file)
Return an iterator over the lines of a file.

boot.janet (2180:1)

## file/open

cfunction

(file/open path &opt mode buffer-size)
Open a file. `path` is an absolute or relative path, and `mode` is a set of flags indicating the mode to open the file in. `mode` is a keyword where each character represents a flag. If the file cannot be opened, returns nil, otherwise returns the new file handle. Mode flags:
* r - allow reading from the file
* w - allow writing to the file
* a - append to the file
Following one of the initial flags, 0 or more of the following flags can be appended:
* b - open the file in binary mode (rather than text mode)
* + - append to the file instead of overwriting it
* n - error if the file cannot be opened instead of returning nil
See fopen (<stdio.h>, C99) for further details.

../janet/src/core/io.c (141:1)

## file/read

cfunction

(file/read f what &opt buf)
Read a number of bytes from a file `f` into a buffer. A buffer `buf` can be provided as an optional third argument, otherwise a new buffer is created. `what` can either be an integer or a keyword. Returns the buffer with file contents. Values for `what`:
* :all - read the whole file
* :line - read up to and including the next newline character
* n (integer) - read up to n bytes from the file

../janet/src/core/io.c (205:1)

## file/seek

cfunction

(file/seek f &opt whence n)
Jump to a relative location in the file `f`. `whence` must be one of:
* :cur - jump relative to the current file location
* :set - jump relative to the beginning of the file
* :end - jump relative to the end of the file
By default, `whence` is :cur. Optionally a value `n` may be passed for the relative number of bytes to seek in the file. `n` may be a real number to handle large files of more than 4GB. Returns the file handle.

../janet/src/core/io.c (344:1)

## file/tell

cfunction

(file/tell f)
Get the current value of the file position for file `f`.

../janet/src/core/io.c (378:1)

## file/temp

cfunction

(file/temp)
Open an anonymous temporary file that is removed on close. Raises an error on failure.

../janet/src/core/io.c (127:1)

## file/write

cfunction

(file/write f & bytes)
Writes to a file `f`. Each value of `bytes` must be a string, buffer, symbol, or keyword. Returns the file.

../janet/src/core/io.c (254:1)

## filewatch/add

cfunction

(filewatch/add watcher path flag & more-flags)
Add a path to the watcher. Available flags depend on the current OS, and are as follows:
Windows/MINGW (flags correspond to `FILE_NOTIFY_CHANGE_*` flags in win32 documentation):
FLAGS
* `:all` - trigger an event for all of the below triggers.
* `:attributes` - `FILE_NOTIFY_CHANGE_ATTRIBUTES`
* `:creation` - `FILE_NOTIFY_CHANGE_CREATION`
* `:dir-name` - `FILE_NOTIFY_CHANGE_DIR_NAME`
* `:last-access` - `FILE_NOTIFY_CHANGE_LAST_ACCESS`
* `:last-write` - `FILE_NOTIFY_CHANGE_LAST_WRITE`
* `:security` - `FILE_NOTIFY_CHANGE_SECURITY`
* `:size` - `FILE_NOTIFY_CHANGE_SIZE`
* `:recursive` - watch subdirectories recursively
Linux (flags correspond to `IN_*` flags from <sys/inotify.h>):
* `:access` - `IN_ACCESS`
* `:all` - `IN_ALL_EVENTS`
* `:attrib` - `IN_ATTRIB`
* `:close-nowrite` - `IN_CLOSE_NOWRITE`
* `:close-write` - `IN_CLOSE_WRITE`
* `:create` - `IN_CREATE`
* `:delete` - `IN_DELETE`
* `:delete-self` - `IN_DELETE_SELF`
* `:ignored` - `IN_IGNORED`
* `:modify` - `IN_MODIFY`
* `:move-self` - `IN_MOVE_SELF`
* `:moved-from` - `IN_MOVED_FROM`
* `:moved-to` - `IN_MOVED_TO`
* `:open` - `IN_OPEN`
* `:q-overflow` - `IN_Q_OVERFLOW`
* `:unmount` - `IN_UNMOUNT`
BSDs and macos (flags correspond to `NOTE_*` flags from <sys/event.h>). Not all flags are available on all systems:
* `:all` - `All available NOTE_* flags on the current platform`
* `:attrib` - `NOTE_ATTRIB`
* `:close-write` - `NOTE_CLOSE_WRITE`
* `:close` - `NOTE_CLOSE`
* `:delete` - `NOTE_DELETE`
* `:extend` - `NOTE_EXTEND`
* `:funlock` - `NOTE_FUNLOCK`
* `:link` - `NOTE_LINK`
* `:open` - `NOTE_OPEN`
* `:read` - `NOTE_READ`
* `:rename` - `NOTE_RENAME`
* `:revoke` - `NOTE_REVOKE`
* `:truncate` - `NOTE_TRUNCATE`
* `:write` - `NOTE_WRITE`
EVENT TYPES
On Windows, events will have the following possible types:
* `:unknown`
* `:added`
* `:removed`
* `:modified`
* `:renamed-old`
* `:renamed-new`
On Linux and BSDs, events will have a `:type` corresponding to the possible flags, excluding `:all`.

../janet/src/core/filewatch.c (861:1)

## filewatch/listen

cfunction

(filewatch/listen watcher)
Listen for changes in the watcher.

../janet/src/core/filewatch.c (937:1)

## filewatch/new

cfunction

(filewatch/new channel & default-flags)
Create a new filewatcher that will give events to a channel channel. See `filewatch/add` for available flags.
When an event is triggered by the filewatcher, a struct containing information will be given to channel as with `ev/give`. The contents of the channel depend on the OS, but will contain some common keys:
* `:type` -- the type of the event that was raised.
* `:file-name` -- the base file name of the file that triggered the event.
* `:dir-name` -- the directory name of the file that triggered the event.
Events also will contain keys specific to the host OS.
Windows has no extra properties on events.
Linux and the BSDs have the following extra properties on events:
* `:wd` -- the integer key returned by `filewatch/add` for the path that triggered this. This is a file descriptor integer on BSD and macos.
* `:wd-path` -- the string path for watched directory of file. For files, will be the same as `:file-name`, and for directories, will be the same as `:dir-name`.
* `:cookie` -- a semi-randomized integer used to associate related events, such as :moved-from and :moved-to events.

../janet/src/core/filewatch.c (837:1)

## filewatch/remove

cfunction

(filewatch/remove watcher path)
Remove a path from the watcher.

../janet/src/core/filewatch.c (926:1)

## filewatch/unlisten

cfunction

(filewatch/unlisten watcher)
Stop listening for changes on a given watcher.

../janet/src/core/filewatch.c (946:1)

## filter

function

(filter pred x)
Given a predicate, take only elements from `x` for which `(pred
element)` is truthy. Returns a new array.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type
with suitable `get` and `next` methods.

boot.janet (1242:1)

## find

function

(find pred x &opt dflt)
Find the first value in `x` that satisfies `pred`. If not found,
return `dflt` if given, or `nil` otherwise.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type
with suitable `get` and `next` methods.

boot.janet (1312:1)

## find-index

function

(find-index pred x &opt dflt)
Find the index of `x` for which `pred` is true. If not found, return
`dflt` if provided, or `nil` otherwise.
`x` can be a bytes, indexed, dictionary, or abstract type with
suitable `get` and `next` methods.

boot.janet (1296:1)

## first

function

(first x)
Get the first value in `x`.
If `x` is a non-empty bytes or indexed type value, return the first
element.
If `x` is a fiber, return the fiber's last value or `nil` if there
isn't one yet.
If `x` is an abstract type value with a `get` method, call the method
with a key of `0`.
In all other cases, return `nil`.

boot.janet (893:1)

## flatten

function

(flatten ind)
Returns a depth-first traversal of an indexed type `ind` as a new
array.

boot.janet (2062:1)

## flatten-into

function

(flatten-into into ind)
Appends the depth-first traversal of an indexed type `ind` into a
given array `into`. Returns `into`.

boot.janet (2050:1)

## flush

cfunction

(flush)
Flush `(dyn :out stdout)` if it is a file, otherwise do nothing.

../janet/src/core/io.c (726:1)

## flycheck

function

(flycheck path &keys kwargs)
Check a file for errors without running the file. Found errors
will be printed to stderr in the usual format. Top level functions
and macros that have the metadata `:flycheck` will also be evaluated
during flychecking. For full control, the `:flycheck` metadata can
also be a function that takes 4 arguments - `thunk`, `source`, `env`,
and `where`, the same as the `:evaluator` argument to `run-context`.
Other arguments to `flycheck` are the same as `dofile`. Returns nil.

boot.janet (4399:1)

## for

macro

(for i start stop & body)
Do a C-style for-loop for side effects. Returns nil.

boot.janet (595:1)

## forever

macro

(forever & body)
Evaluate body forever in a loop, or until a break statement.

boot.janet (639:1)

## forv

macro

(forv i start stop & body)
Do a C-style for-loop for side effects. The iteration variable `i`
can be mutated in the loop, unlike normal `for`. Returns nil.

boot.janet (589:1)

## freeze

function

(freeze x)
Freeze an object (make it immutable) and do a deep copy, making
child values also immutable. Closures, fibers, and abstract types
will not be recursively frozen, but all other types will.

boot.janet (2559:1)

## frequencies

function

(frequencies x)
Returns a table of occurrences of each value in `x`.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type
with `get` and `next` methods.

boot.janet (1974:1)

## from-pairs

function

(from-pairs ps)
Takes a sequence of pairs and creates a table from each pair. It is the inverse of
`pairs` on a table. Returns a new table.

boot.janet (2078:1)

## function?

function

(function? x)
Check if x is a function (not a cfunction).

boot.janet (106:1)

## gccollect

cfunction

(gccollect)
Run garbage collection. You should probably not call this manually.

../janet/src/core/corelib.c (542:1)

## gcinterval

cfunction

(gcinterval)
Returns the integer number of bytes to allocate before running an iteration of garbage collection.

../janet/src/core/corelib.c (568:1)

## gcsetinterval

cfunction

(gcsetinterval interval)
Set an integer number of bytes to allocate before running garbage collection. Low values for interval will be slower but use less memory. High values will be faster but use more memory.

../janet/src/core/corelib.c (551:1)

## generate

macro

(generate head & body)
Create a generator expression using the `loop` syntax. Returns a fiber
that yields all values inside the loop in order. See `loop` for details.

boot.janet (755:1)

## gensym

cfunction

(gensym)
Returns a new symbol that is unique across the runtime. This means it will not collide with any already created symbols during compilation, so it can be used in macros to generate automatic bindings.

../janet/src/core/corelib.c (532:1)

## geomean

function

(geomean x)
Returns the geometric mean of the values of `x`. If empty, returns
`math/nan`.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type
with suitable `get` and `next` methods.

boot.janet (799:1)

## get

function

(get x key &opt dflt)
Get the value mapped to `key` in `x`. Returns `dflt` or `nil` if `key` is not found. Similar to `in`, but will not throw an error if `key` is invalid for `x`. However, if `x` is an abstract type, its getter may throw an error.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type with a suitable `get` method.

## get-in

function

(get-in x ks &opt dflt)
Use the keys `ks` to look up a nested value in `x`. If a value is
not found, will return `dflt` if provided, or `nil` otherwise.
`x` can be a suitable indexed, dictionary, or abstract type with a
`get` method.
`ks` can be an indexed or abstract type with `get` and `next`
methods.

boot.janet (1805:1)

## getline

cfunction

(getline &opt prompt buf env)
Reads a line of input into a buffer, including the newline character, using a prompt. An optional environment table can be provided for auto-complete. Returns the modified buffer. Use this function to implement a simple interface for a terminal program.

../janet/src/core/corelib.c (614:1)

## getproto

cfunction

(getproto x)
Get the prototype of a table or struct. Will return nil if `x` has no prototype.

../janet/src/core/corelib.c (496:1)

## group-by

function

(group-by f x)
Group values of `x` by a function `f` and put the results into a new
table. The keys of the table are the distinct return values from
calling `f` on the values of `x`. The values of the table are arrays
of all values of `x` for which `f` called on the value equals that
corresponding key.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type
with suitable `get` and `next` methods.

boot.janet (1987:1)

## has-key?

function

(has-key? x key)
Check if `x` maps `key` to a non-nil value.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type
with a suitable `get` method.

boot.janet (1472:1)

## has-value?

function

(has-value? x value)
Checks if `x` contains `value`.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type with
suitable `get` and `next` methods.

boot.janet (1482:1)

## hash

cfunction

(hash value)
Gets a hash for any value. The hash is an integer can be used as a cheap hash function for all values. If two values are strictly equal, then they will have the same hash value.

../janet/src/core/corelib.c (605:1)

## idempotent?

function

(idempotent? x)
Check if x is a value that evaluates to itself when compiled.

boot.janet (130:1)

## identity

function

(identity x)
A function that returns its argument.

boot.janet (850:1)

## if-let

macro

(if-let bindings tru &opt fal)
Make multiple bindings, and if all are truthy,
evaluate the `tru` form. If any are false or nil, evaluate
the `fal` form. Bindings have the same syntax as the `let` macro.

boot.janet (448:1)

## if-not

macro

(if-not condition then &opt else)
Shorthand for `(if (not condition) else then)`.

boot.janet (229:1)

## if-with

macro

(if-with [binding ctor dtor] truthy &opt falsey)
Similar to `with`, but if binding is false or nil, evaluates
the falsey path. Otherwise, evaluates the truthy path. In both cases,
`ctor` is bound to binding.

boot.janet (477:1)

## import

macro

(import path & args)
Import a module. First requires the module, and then merges its
symbols into the current environment, prepending a given prefix as needed.
(use the :as or :prefix option to set a prefix). If no prefix is provided,
use the name of the module as a prefix. One can also use "`:export true`"
to re-export the imported symbols. If "`:exit true`" is given as an argument,
any errors encountered at the top level in the module will cause `(os/exit 1)`
to be called. Dynamic bindings will NOT be imported. Use :fresh with a truthy
value to bypass the module cache. Use `:only [foo bar baz]` to only import
select bindings into the current environment.

boot.janet (3520:1)

## import*

function

(import* path & args)
Function form of `import`. Same parameters, but the path
and other symbol parameters should be strings instead.

boot.janet (3503:1)

## in

function

(in x key &opt dflt)
Get value in `x` at `key`. For bytes and indexed types, `key` must be a non-negative interger in bounds or an error is raised. For dictionaries `key` must be a non-nil value and if not found, will return `dflt` if provided or `nil` otherwise.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type with a suitable `get` method.

## inc

function

(inc x)
Returns x + 1.

boot.janet (136:1)

## index-of

function

(index-of val x &opt dflt)
Find the first key associated with a value `val` in `x`, acting like
a reverse lookup. Will not look at dictionary prototypes. If not
found, return `dflt` if given, or `nil` otherwise.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type
with suitable `get` and `next` methods.

boot.janet (1329:1)

## indexed?

cfunction

(indexed? x)
Check if x is an array or tuple.

../janet/src/core/corelib.c (684:1)

## int/s64

cfunction

(int/s64 value)
Create a boxed signed 64 bit integer from a string value or a number.

../janet/src/core/inttypes.c (192:1)

## int/to-bytes

cfunction

(int/to-bytes value &opt endianness buffer)
Write the bytes of an `int/s64` or `int/u64` into a buffer.
The `buffer` parameter specifies an existing buffer to write to, if unset a new buffer will be created.
Returns the modified buffer.
The `endianness` parameter indicates the byte order:
- `nil` (unset): system byte order
- `:le`: little-endian, least significant byte first
- `:be`: big-endian, most significant byte first

../janet/src/core/inttypes.c (237:1)

## int/to-number

cfunction

(int/to-number value)
Convert an int/u64 or int/s64 to a number. Fails if the number is out of range for an int64.

../janet/src/core/inttypes.c (206:1)

## int/u64

cfunction

(int/u64 value)
Create a boxed unsigned 64 bit integer from a string value or a number.

../janet/src/core/inttypes.c (199:1)

## int?

cfunction

(int? x)
Check if x can be exactly represented as a 32 bit signed two's complement integer.

../janet/src/core/corelib.c (662:1)

## interleave

function

(interleave & xs)
Returns an array of the values of each element of `xs`, interleaved.
If the elements of `xs` do not all have the same number of values,
the shortest element of `xs` determines the number of values from
each element of `xs` that are contained in the returned array.
Each element of `xs` can be a bytes, indexed, fiber, or abstract
type with suitable `get` and `next` methods.

boot.janet (2029:1)

## interpose

function

(interpose sep x)
Returns an array of the values of `x` separated by `sep`.
`x` can be a bytes, indexed, fiber or abstract type with suitable
`get` and `next` methods.

boot.janet (2087:1)

## invert

function

(invert x)
Returns a table where the keys of `x` are the values, and the values
are the keys. If multiple keys in `x` are mapped to the same value,
only one of those values will become a key in the returned table.
`x` can be a bytes, indexed, dictionary, or abstract type with a
`suitable next` method.

boot.janet (1775:1)

## janet/build

string

The build identifier of the running janet program.

## janet/config-bits

number

The flag set of config options from janetconf.h which is used to check if native modules are compatible with the host program.

## janet/version

string

The version number of the running janet program.

## juxt

macro

(juxt & funs)
Macro form of `juxt*`. Same behavior but more efficient.

boot.janet (1463:1)

## juxt*

function

(juxt* & funs)
Returns the juxtaposition of functions. In other words,
`((juxt* a b c) x)` evaluates to `[(a x) (b x) (c x)]`.

boot.janet (1453:1)

## keep

function

(keep pred x & xs)
Given a predicate `pred`, return a new array containing the truthy
results of applying `pred` to each value in `x`.
Also functions variadically, i.e. takes additional arguments, with
suitable changes to the arity of `pred`. `pred` is called with both
values from `x` and additional arguments, and only as many times as
the length of the shortest of `x` and each element of `xs`. If `x`
or any element of `xs` is empty, returns an empty array.
`x` and elements of `xs` can be values of type bytes, indexed,
dictionary, fiber, or abstract with suitable `get` and `next`
methods.

boot.janet (1276:1)

## keep-syntax

function

(keep-syntax before after)
Creates a tuple with the tuple type and sourcemap of `before` but the
elements of `after`. If either one of its arguments is not a tuple, returns
`after` unmodified. Useful to preserve syntactic information when transforming
an ast in macros.

boot.janet (1521:1)

## keep-syntax!

function

(keep-syntax! before after)
Like `keep-syntax`, but if `after` is an array, it is coerced into a tuple.
Useful to preserve syntactic information when transforming an ast in macros.

boot.janet (1536:1)

## keys

function

(keys x)
Get the keys of `x` as an array.
`x` can be a bytes, indexed, dictionary, or abstract type with a
suitable `next` method.

boot.janet (1919:1)

## keyword

cfunction

(keyword & xs)
Creates a keyword by concatenating the elements of `xs` together. If an element is not a byte sequence, it is converted to bytes via `describe`. Returns the new keyword.

../janet/src/core/corelib.c (352:1)

## keyword/slice

cfunction

(keyword/slice bytes &opt start end)
Same as string/slice, but returns a keyword.

../janet/src/core/string.c (194:1)

## keyword?

function

(keyword? x)
Check if x is a keyword.

boot.janet (104:1)

## kvs

function

(kvs dict)
Takes a table or struct and returns a new array of key value pairs
like `@[k v k v ...]`.

boot.janet (2070:1)

## label

macro

(label name & body)
Set a label point that is lexically scoped. `name` should be a symbol
that will be bound to the label.

boot.janet (422:1)

## last

function

(last x)
Get the final element from `x`.
`x` can be a bytes, indexed, or abstract type value with suitable
`get` and `length` methods.

boot.janet (911:1)

## length

function

(length x)
Returns the length or count of `x` as an integer. Returns are guaranteed to be in constant time except for abstract types. For dictionaries, returns the number of key-value pairs.
`x` can be a bytes, indexed, dictionary, or abstract type with a suitable `length` method.

## lengthable?

cfunction

(lengthable? x)
Check if x is a bytes, indexed, or dictionary.

../janet/src/core/corelib.c (698:1)

## let

macro

(let bindings & body)
Create a scope and bind values to symbols. Each pair in `bindings` is
assigned as if with `def`, and the body of the `let` form returns the last
value.

boot.janet (279:1)

## load-image

function

(load-image image)
The inverse operation to `make-image`. Returns an environment.

boot.janet (3144:1)

## load-image-dict

table

A table used in combination with `unmarshal` to unmarshal byte sequences created
by `make-image`, such that `(load-image bytes)` is the same as `(unmarshal bytes load-image-dict)`.

boot.janet (3109:1)

## loop

macro

(loop head & body)
A general purpose loop macro. This macro is similar to the Common
Lisp `loop` macro, although intentionally much smaller in scope.
The first argument, `head`, should be a tuple that contains a
sequence of either bindings or conditionals. A binding is a sequence
of three values that define something to loop over. Bindings are
written in the format:
binding :verb object/expression
where `binding` is a binding as passed to `def`, `:verb` is one of a
set of keywords, and `object` is any expression. Each subsequent
binding creates a nested loop within the loop created by the
previous binding.
The available verbs are:
* `:iterate` -- repeatedly evaluate and bind to the expression while
it is truthy.
* `:range` -- loop over a range. The object should be a two-element
tuple with a start and end value, and an optional positive
step. The range is half open, [start, end).
* `:range-to` -- same as `:range`, but the range is inclusive
[start, end].
* `:down` -- loop over a range, stepping downwards. The object
should be a two-element tuple with a start and end value, and an
optional positive step size. The range is half open, [start,
end).
* `:down-to` -- same as `:down`, but the range is inclusive [start,
end].
* `:keys` -- iterate over the keys in a bytes, indexed, dictionary,
fiber, or abstract type with a suitable `next` method.
* `:pairs` -- iterate over the key-value pairs as tuples in a bytes,
indexed, dictionary, fiber, or abstract type with suitable `get`
and `next` methods.
* `:in` -- iterate over the values in a bytes, indexed, dictionary,
fiber, or abstract type with suitable `get` and `next` methods.
`loop` also accepts conditionals to refine the looping
further. Conditionals are of the form:
:modifier argument
where `:modifier` is one of a set of keywords, and `argument` is
keyword-dependent. `:modifier` can be one of:
* `:while expression` -- breaks from the current loop if
`expression` is falsey.
* `:until expression` -- breaks from the current loop if
`expression` is truthy.
* `:let bindings` -- defines bindings inside the current loop as
passed to the `let` macro.
* `:before form` -- evaluates a form for a side effect before the
next inner loop.
* `:after form` -- same as `:before`, but the side effect happens
after the next inner loop.
* `:repeat n` -- repeats the next inner loop `n` times.
* `:when condition` -- only evaluates the current loop body when
`condition` is truthy.
* `:unless condition` -- only evaluates the current loop body when
`condition` is falsey.
The `loop` macro always evaluates to `nil`.

boot.janet (649:1)

## macex

function

(macex x &opt on-binding)
Expand macros completely.
`on-binding` is an optional callback for whenever a normal symbolic binding
is encountered. This allows macros to easily see all bindings used by their
arguments by calling `macex` on their contents. The binding itself is also
replaced by the value returned by `on-binding` within the expanded macro.

boot.janet (2649:1)

## macex1

function

(macex1 x &opt on-binding)
Expand macros in a form, but do not recursively expand macros.
See `macex` docs for info on `on-binding`.

boot.janet (2416:1)

## maclintf

function

(maclintf level fmt & args)
When inside a macro, call this function to add a linter warning. Takes
a `fmt` argument like `string/format`, which is used to format the message.

boot.janet (189:1)

## make-env

function

(make-env &opt parent)
Create a new environment table. The new environment
will inherit bindings from the parent environment, but new
bindings will not pollute the parent environment.

boot.janet (2803:1)

## make-image

function

(make-image env)
Create an image from an environment returned by `require`.
Returns the image source as a string.

boot.janet (3138:1)

## make-image-dict

table

A table used in combination with `marshal` to marshal code (images), such that
`(make-image x)` is the same as `(marshal x make-image-dict)`.

boot.janet (3114:1)

## map

function

(map f x & xs)
Map a function `f` over every value in `x` and return an array of
results.
Also functions variadically, i.e. takes additional arguments, with
suitable changes to the arity of `f`. `f` is called with both values
from `x` and additional arguments, and only as many times as the
length of the shortest of `x` and each element of `xs`. If `x` or
any element of `xs` is empty, returns an empty array.
`x` and elements of `xs` can be values of type bytes, indexed,
dictionary, fiber, or abstract with suitable `get` and `next`
methods.

boot.janet (1202:1)

## mapcat

function

(mapcat f x & xs)
Map a function `f` over every value in `x` and use `array/concat` to
concatenate the results.
Also functions variadically, i.e. takes additional arguments, with
suitable changes to the arity of `f`. `f` is called with both values
from `x` and additional arguments, and only as many times as the
length of the shortest of `x` and each element of `xs`. If `x` or
any element of `xs` is empty, returns an empty array.
`x` and elements of `xs` can be values of type bytes, indexed,
dictionary, fiber, or abstract with suitable `get` and `next`
methods.

boot.janet (1222:1)

## marshal

cfunction

(marshal x &opt reverse-lookup buffer no-cycles)
Marshal a value into a buffer and return the buffer. The buffer can then later be unmarshalled to reconstruct the initial value. Optionally, one can pass in a reverse lookup table to not marshal aliased values that are found in the table. Then a forward lookup table can be used to recover the original value when unmarshalling.

../janet/src/core/marsh.c (1681:1)

## match

macro

(match x & cases)
Pattern matching. Match an expression `x` against any number of cases.
Each case is a pattern to match against, followed by an expression to
evaluate to if that case is matched. Legal patterns are:
* symbol -- a pattern that is a symbol will match anything, binding `x`'s
value to that symbol.
* array or bracket tuple -- an array or bracket tuple will match only if
all of its elements match the corresponding elements in `x`.
Use `& rest` at the end of an array or bracketed tuple to bind all remaining values to `rest`.
* table or struct -- a table or struct will match if all values match with
the corresponding values in `x`.
* tuple -- a tuple pattern will match if its first element matches, and the
following elements are treated as predicates and are true.
* `_` symbol -- the last special case is the `_` symbol, which is a wildcard
that will match any value without creating a binding.
While a symbol pattern will ordinarily match any value, the pattern `(@ <sym>)`,
where `<sym>` is any symbol, will attempt to match `x` against a value
already bound to `<sym>`, rather than matching and rebinding it.
Any other value pattern will only match if it is equal to `x`.
Quoting a pattern with `'` will also treat the value as a literal value to match against.

boot.janet (2193:1)

## math/-inf

number

The number representing negative infinity

../janet/src/core/math.c (437:1)

## math/abs

cfunction

(math/abs x)
Return the absolute value of x.

../janet/src/core/math.c (297:1)

## math/acos

cfunction

(math/acos x)
Returns the arccosine of x.

../janet/src/core/math.c (266:1)

## math/acosh

cfunction

(math/acosh x)
Returns the hyperbolic arccosine of x.

../janet/src/core/math.c (271:1)

## math/asin

cfunction

(math/asin x)
Returns the arcsin of x.

../janet/src/core/math.c (267:1)

## math/asinh

cfunction

(math/asinh x)
Returns the hyperbolic arcsine of x.

../janet/src/core/math.c (287:1)

## math/atan

cfunction

(math/atan x)
Returns the arctangent of x.

../janet/src/core/math.c (268:1)

## math/atan2

cfunction

(math/atan2 y x)
Returns the arctangent of y/x. Works even when x is 0.

../janet/src/core/math.c (307:1)

## math/atanh

cfunction

(math/atanh x)
Returns the hyperbolic arctangent of x.

../janet/src/core/math.c (286:1)

## math/cbrt

cfunction

(math/cbrt x)
Returns the cube root of x.

../janet/src/core/math.c (281:1)

## math/ceil

cfunction

(math/ceil x)
Returns the smallest integer value number that is not less than x.

../janet/src/core/math.c (293:1)

## math/cos

cfunction

(math/cos x)
Returns the cosine of x.

../janet/src/core/math.c (269:1)

## math/cosh

cfunction

(math/cosh x)
Returns the hyperbolic cosine of x.

../janet/src/core/math.c (270:1)

## math/e

number

The base of the natural log.

../janet/src/core/math.c (433:1)

## math/erf

cfunction

(math/erf x)
Returns the error function of x.

../janet/src/core/math.c (282:1)

## math/erfc

cfunction

(math/erfc x)
Returns the complementary error function of x.

../janet/src/core/math.c (283:1)

## math/exp

cfunction

(math/exp x)
Returns e to the power of x.

../janet/src/core/math.c (276:1)

## math/exp2

cfunction

(math/exp2 x)
Returns 2 to the power of x.

../janet/src/core/math.c (277:1)

## math/expm1

cfunction

(math/expm1 x)
Returns e to the power of x minus 1.

../janet/src/core/math.c (280:1)

## math/floor

cfunction

(math/floor x)
Returns the largest integer value number that is not greater than x.

../janet/src/core/math.c (294:1)

## math/frexp

cfunction

(math/frexp x)
Returns a tuple of (mantissa, exponent) from number.

../janet/src/core/math.c (356:1)

## math/gamma

cfunction

(math/gamma x)
Returns gamma(x).

../janet/src/core/math.c (285:1)

## math/gcd

cfunction

(math/gcd x y)
Returns the greatest common divisor between x and y.

../janet/src/core/math.c (340:1)

## math/hypot

cfunction

(math/hypot a b)
Returns c from the equation c^2 = a^2 + b^2.

../janet/src/core/math.c (309:1)

## math/inf

number

The number representing positive infinity

../janet/src/core/math.c (435:1)

## math/int-max

number

The maximum contiguous integer representable by a double (2^53)

../janet/src/core/math.c (445:1)

## math/int-min

number

The minimum contiguous integer representable by a double (-(2^53))

../janet/src/core/math.c (443:1)

## math/int32-max

number

The maximum contiguous integer representable by a 32 bit signed integer

../janet/src/core/math.c (441:1)

## math/int32-min

number

The minimum contiguous integer representable by a 32 bit signed integer

../janet/src/core/math.c (439:1)

## math/lcm

cfunction

(math/lcm x y)
Returns the least common multiple of x and y.

../janet/src/core/math.c (348:1)

## math/ldexp

cfunction

(math/ldexp m e)
Creates a new number from a mantissa and an exponent.

../janet/src/core/math.c (368:1)

## math/log

cfunction

(math/log x)
Returns the natural logarithm of x.

../janet/src/core/math.c (289:1)

## math/log-gamma

cfunction

(math/log-gamma x)
Returns log-gamma(x).

../janet/src/core/math.c (284:1)

## math/log10

cfunction

(math/log10 x)
Returns the log base 10 of x.

../janet/src/core/math.c (290:1)

## math/log1p

cfunction

(math/log1p x)
Returns (log base e of x) + 1 more accurately than (+ (math/log x) 1)

../janet/src/core/math.c (278:1)

## math/log2

cfunction

(math/log2 x)
Returns the log base 2 of x.

../janet/src/core/math.c (291:1)

## math/nan

number

Not a number (IEEE-754 NaN)

../janet/src/core/math.c (448:1)

## math/next

cfunction

(math/next x y)
Returns the next representable floating point value after x in the direction of y.

../janet/src/core/math.c (311:1)

## math/pi

number

The value pi.

../janet/src/core/math.c (431:1)

## math/pow

cfunction

(math/pow a x)
Returns a to the power of x.

../janet/src/core/math.c (308:1)

## math/random

cfunction

(math/random)
Returns a uniformly distributed random number between 0 and 1.

../janet/src/core/math.c (232:1)

## math/rng

cfunction

(math/rng &opt seed)
Creates a Pseudo-Random number generator, with an optional seed. The seed should be an unsigned 32 bit integer or a buffer. Do not use this for cryptography. Returns a core/rng abstract type.

../janet/src/core/math.c (120:1)

## math/rng-buffer

cfunction

(math/rng-buffer rng n &opt buf)
Get n random bytes and put them in a buffer. Creates a new buffer if no buffer is provided, otherwise appends to the given buffer. Returns the buffer.

../janet/src/core/math.c (183:1)

## math/rng-int

cfunction

(math/rng-int rng &opt max)
Extract a random integer in the range [0, max) for max > 0 from the RNG. If max is 0, return 0. If no max is given, the default is 2^31 - 1.

../janet/src/core/math.c (151:1)

## math/rng-uniform

cfunction

(math/rng-uniform rng)
Extract a random number in the range [0, 1) from the RNG.

../janet/src/core/math.c (142:1)

## math/round

cfunction

(math/round x)
Returns the integer nearest to x.

../janet/src/core/math.c (296:1)

## math/seedrandom

cfunction

(math/seedrandom seed)
Set the seed for the random number generator. `seed` should be an integer or a buffer.

../janet/src/core/math.c (241:1)

## math/sin

cfunction

(math/sin x)
Returns the sine of x.

../janet/src/core/math.c (272:1)

## math/sinh

cfunction

(math/sinh x)
Returns the hyperbolic sine of x.

../janet/src/core/math.c (273:1)

## math/sqrt

cfunction

(math/sqrt x)
Returns the square root of x.

../janet/src/core/math.c (292:1)

## math/tan

cfunction

(math/tan x)
Returns the tangent of x.

../janet/src/core/math.c (274:1)

## math/tanh

cfunction

(math/tanh x)
Returns the hyperbolic tangent of x.

../janet/src/core/math.c (275:1)

## math/trunc

cfunction

(math/trunc x)
Returns the integer between x and 0 nearest to x.

../janet/src/core/math.c (295:1)

## max

function

(max & args)
Returns the numeric maximum of the arguments.

boot.janet (877:1)

## max-of

function

(max-of args)
Returns the numeric maximum of the argument sequence.

boot.janet (885:1)

## mean

function

(mean x)
Returns the mean of the values of `x`. If empty, returns `math/nan`.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type
with suitable `get` and `next` methods.

boot.janet (784:1)

## memcmp

cfunction

(memcmp a b &opt len offset-a offset-b)
Compare memory. Takes two byte sequences `a` and `b`, and return 0 if they have identical contents, a negative integer if a is less than b, and a positive integer if a is greater than b. Optionally take a length and offsets to compare slices of the bytes sequences.

../janet/src/core/corelib.c (735:1)

## merge

function

(merge & dicts)
Merges multiple dictionaries into one new table. If a key appears in
more than one dictionary in `dicts` then later values replace any
previous ones. Returns the new table.

boot.janet (1906:1)

## merge-into

function

(merge-into tab & dicts)
Merges multiple dictionaries into table `tab`. If a key appears in
more than one dictionary in `dicts`, then later values replace any
previous ones. Returns `tab`.

boot.janet (1894:1)

## merge-module

function

(merge-module target source &opt prefix export only)
Merge a module source into the `target` environment with a `prefix`, as with the `import` macro.
This lets users emulate the behavior of `import` with a custom module table.
If `export` is truthy, then merged functions are not marked as private. Returns
the modified target environment. If a tuple or array `only` is passed, only merge keys in `only`.

boot.janet (3491:1)

## min

function

(min & args)
Returns the numeric minimum of the arguments.

boot.janet (881:1)

## min-of

function

(min-of args)
Returns the numeric minimum of the argument sequence.

boot.janet (889:1)

## mod

function

(mod & xs)
Returns the result of applying the modulo operator on the first value of xs with each remaining value. `(mod x 0)` is defined to be `x`.

## module/add-file-extension

function

(module/add-file-extension ext loader)
Add paths to `module/paths` for a given file extension such that
the programmer can import a module by relative or absolute path from
the current working directory.
Returns the modified `module/paths`.

boot.janet (3204:1)

## module/add-paths

function

(module/add-paths ext loader)
Add paths to `module/paths` for a given loader such that
the generated paths behave like other module types, including
relative imports and syspath imports. `ext` is the file extension
to associate with this module type, including the dot. `loader` is the
keyword name of a loader in `module/loaders`. Returns the modified `module/paths`.

boot.janet (3181:1)

## module/add-syspath

function

(module/add-syspath path)
Add a custom syspath to `module/paths` by duplicating all entries that being with `:sys:` and
adding duplicates with a specific path prefix instead.

boot.janet (3217:1)

## module/cache

table

A table, mapping loaded module identifiers to their environments.

boot.janet (3162:1)

## module/expand-path

cfunction

(module/expand-path path template)
Expands a path template as found in `module/paths` for `module/find`. This takes in a path (the argument to require) and a template string, to expand the path to a path that can be used for importing files. The replacements are as follows:
* :all: -- the value of path verbatim.
* :@all: -- Same as :all:, but if `path` starts with the @ character, the first path segment is replaced with a dynamic binding `(dyn <first path segment as keyword>)`.
* :cur: -- the directory portion, if any, of (dyn :current-file)
* :dir: -- the directory portion, if any, of the path argument
* :name: -- the name component of path, with extension if given
* :native: -- the extension used to load natives, .so or .dll
* :sys: -- the system path, or (dyn :syspath)

../janet/src/core/corelib.c (110:1)

## module/find

function

(module/find path &opt find-all)
Try to match a module or path name from the patterns in `module/paths`.
Returns a tuple (fullpath kind) where the kind is one of :source, :native,
or :image if the module is found, otherwise a tuple with nil followed by
an error message.

boot.janet (3268:1)

## module/loaders

table

A table of loading method names to loading functions.
This table lets `require` and `import` load many different kinds
of files as modules.

boot.janet (3445:1)

## module/loading

table

A table, mapping currently loading modules to true. Used to prevent
circular dependencies.

boot.janet (3300:1)

## module/paths

array

The list of paths to look for modules, templated for `module/expand-path`.
Each element is a two-element tuple, containing the path
template and a keyword :source, :native, or :image indicating how
`require` should load files found at these paths.
A tuple can also
contain a third element, specifying a filter that prevents `module/find`
from searching that path template if the filter doesn't match the input
path. The filter can be a string or a predicate function, and
is often a file extension, including the period.

boot.janet (3166:1)

## module/value

function

(module/value module sym &opt private)
Given a module table, get the value bound to a symbol `sym`. If `private` is
truthy, will also resolve private module symbols. If no binding is found, will return
nil.

boot.janet (3305:1)

## nan?

function

(nan? x)
Check if x is NaN.

boot.janet (99:1)

## nat?

cfunction

(nat? x)
Check if x can be exactly represented as a non-negative 32 bit signed two's complement integer.

../janet/src/core/corelib.c (669:1)

## native

cfunction

(native path &opt env)
Load a native module from the given path. The path must be an absolute or relative path on the file system, and is usually a .so file on Unix systems, and a .dll file on Windows. Returns an environment table that contains functions and other values from the native module.

../janet/src/core/corelib.c (289:1)

## neg?

function

(neg? x)
Check if x is less than 0.

boot.janet (988:1)

## net/accept

cfunction

(net/accept stream &opt timeout)
Get the next connection on a server stream. This would usually be called in a loop in a dedicated fiber. Takes an optional timeout in seconds, after which will raise an error. Returns a new duplex stream which represents a connection to the client.

../janet/src/core/net.c (997:1)

## net/accept-loop

cfunction

(net/accept-loop stream handler)
Shorthand for running a server stream that will continuously accept new connections. Blocks the current fiber until the stream is closed, and will return the stream.

../janet/src/core/net.c (985:1)

## net/address

cfunction

(net/address host port &opt type multi)
Look up the connection information for a given hostname, port, and connection type. Returns a handle that can be used to send datagrams over network without establishing a connection. On Posix platforms, you can use :unix for host to connect to a unix domain socket, where the name is given in the port argument. On Linux, abstract unix domain sockets are specified with a leading '@' character in port. If `multi` is truthy, will return all address that match in an array instead of just the first.

../janet/src/core/net.c (453:1)

## net/address-unpack

cfunction

(net/address-unpack address)
Given an address returned by net/address, return a host, port pair. Unix domain sockets will have only the path in the returned tuple.

../janet/src/core/net.c (976:1)

## net/chunk

cfunction

(net/chunk stream nbytes &opt buf timeout)
Same a net/read, but will wait for all n bytes to arrive rather than return early. Takes an optional timeout in seconds, after which will raise an error.

../janet/src/core/net.c (1032:1)

## net/close

function

(net/close stream)
Alias for `ev/close`.

boot.janet (4163:3)

## net/connect

cfunction

(net/connect host port &opt type bindhost bindport)
Open a connection to communicate with a server. Returns a duplex stream that can be used to communicate with the server. Type is an optional keyword to specify a connection type, either :stream or :datagram. The default is :stream. Bindhost is an optional string to select from what address to make the outgoing connection, with the default being the same as using the OS's preferred address.

../janet/src/core/net.c (501:1)

## net/flush

cfunction

(net/flush stream)
Make sure that a stream is not buffering any data. This temporarily disables Nagle's algorithm. Use this to make sure data is sent without delay. Returns stream.

../janet/src/core/net.c (1099:1)

## net/listen

cfunction

(net/listen host port &opt type no-reuse)
Creates a server. Returns a new stream that is neither readable nor writeable. Use net/accept or net/accept-loop be to handle connections and start the server. The type parameter specifies the type of network connection, either a :stream (usually tcp), or :datagram (usually udp). If not specified, the default is :stream. The host and port arguments are the same as in net/address. The last boolean parameter `no-reuse` will disable the use of `SO_REUSEADDR` and `SO_REUSEPORT` when creating a server on some operating systems.

../janet/src/core/net.c (809:1)

## net/localname

cfunction

(net/localname stream)
Gets the local address and port in a tuple in that order.

../janet/src/core/net.c (944:1)

## net/peername

cfunction

(net/peername stream)
Gets the remote peer's address and port in a tuple in that order.

../janet/src/core/net.c (960:1)

## net/read

cfunction

(net/read stream nbytes &opt buf timeout)
Read up to n bytes from a stream, suspending the current fiber until the bytes are available. `n` can also be the keyword `:all` to read into the buffer until end of stream. If less than n bytes are available (and more than 0), will push those bytes and return early. Takes an optional timeout in seconds, after which will raise an error. Returns a buffer with up to n more bytes in it, or raises an error if the read failed.

../janet/src/core/net.c (1010:1)

## net/recv-from

cfunction

(net/recv-from stream nbytes buf &opt timeout)
Receives data from a server stream and puts it into a buffer. Returns the socket-address the packet came from. Takes an optional timeout in seconds, after which will raise an error.

../janet/src/core/net.c (1046:1)

## net/send-to

cfunction

(net/send-to stream dest data &opt timeout)
Writes a datagram to a server stream. dest is a the destination address of the packet. Takes an optional timeout in seconds, after which will raise an error. Returns stream.

../janet/src/core/net.c (1079:1)

## net/server

function

(net/server host port &opt handler type no-reuse)
Starts a server with `net/listen`. Runs `net/accept-loop` asynchronously if
`handler` is set and `type` is `:stream` (the default). It is invalid to set
`handler` if `type` is `:datagram`. Returns the new server stream.

boot.janet (4279:3)

## net/setsockopt

cfunction

(net/setsockopt stream option value)
set socket options.
supported options and associated value types:
- :so-broadcast boolean
- :so-reuseaddr boolean
- :so-keepalive boolean
- :ip-multicast-ttl number
- :ip-add-membership string
- :ip-drop-membership string
- :ipv6-join-group string
- :ipv6-leave-group string
- :ipv6-multicast-hops number
- :ipv6-unicast-hops number

../janet/src/core/net.c (1139:1)

## net/shutdown

cfunction

(net/shutdown stream &opt mode)
Stop communication on this socket in a graceful manner, either in both directions or just reading/writing from the stream. The `mode` parameter controls which communication to stop on the socket.
* `:wr` is the default and prevents both reading new data from the socket and writing new data to the socket.
* `:r` disables reading new data from the socket.
* `:w` disable writing data to the socket.
Returns the original socket.

../janet/src/core/net.c (771:1)

## net/socket

cfunction

(net/socket &opt type address-family)
Creates a new unbound socket. Type is an optional keyword, either a :stream (usually tcp), or :datagram (usually udp). The default is :stream. `address-family` should be one of :ipv4 or :ipv6.

../janet/src/core/net.c (682:1)

## net/write

cfunction

(net/write stream data &opt timeout)
Write data to a stream, suspending the current fiber until the write completes. Takes an optional timeout in seconds, after which will raise an error. Returns nil, or raises an error if the write failed.

../janet/src/core/net.c (1060:1)

## next

function

(next x &opt key)
Gets the next key in `x`. Can be used to iterate through the keys of `x` in an unspecified order. Keys are guaranteed to be seen only once per iteration if `x` is not mutated during iteration. If `key` is `nil`, returns the first key. If `nil` is returned, there are no more keys to iterate through.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type with a suitable `next` method.

## nil?

function

(nil? x)
Check if x is nil.

boot.janet (116:1)

## not

cfunction

(not x)
Returns the boolean inverse of x.

../janet/src/core/math.c (314:1)

## not=

function

(not= & xs)
Check if any values in xs are not equal. Returns a boolean.

## number?

function

(number? x)
Check if x is a number.

boot.janet (100:1)

## odd?

function

(odd? x)
Check if x is odd.

boot.janet (991:1)

## one?

function

(one? x)
Check if x is equal to 1.

boot.janet (989:1)

## or

macro

(or & forms)
Evaluates to the last argument if all preceding elements are falsey, otherwise
evaluates to the first truthy element.

boot.janet (323:1)

## os/arch

cfunction

(os/arch)
Check the ISA that janet was compiled for. Returns one of:
* :x86
* :x64
* :arm
* :aarch64
* :riscv32
* :riscv64
* :sparc
* :wasm
* :s390
* :s390x
* :unknown

../janet/src/core/os.c (206:1)

## os/cd

cfunction

(os/cd path)
Change current directory to path. Returns nil on success, errors on failure.

../janet/src/core/os.c (2205:1)

## os/chmod

cfunction

(os/chmod path mode)
Change file permissions, where `mode` is a permission string as returned by `os/perm-string`, or an integer as returned by `os/perm-int`. When `mode` is an integer, it is interpreted as a Unix permission value, best specified in octal, like 8r666 or 8r400. Windows will not differentiate between user, group, and other permissions, and thus will combine all of these permissions. Returns nil.Unsupported on plan9.

../janet/src/core/os.c (2556:1)

## os/clock

cfunction

(os/clock &opt source format)
Return the current time of the requested clock source.
The `source` argument selects the clock source to use, when not specified the default is `:realtime`:
- :realtime: Return the real (i.e., wall-clock) time. This clock is affected by discontinuous jumps in the system time
- :monotonic: Return the number of whole + fractional seconds since some fixed point in time. The clock is guaranteed to be non-decreasing in real time.
- :cputime: Return the CPU time consumed by this process (i.e. all threads in the process)
The `format` argument selects the type of output, when not specified the default is `:double`:
- :double: Return the number of seconds + fractional seconds as a double
- :int: Return the number of seconds as an integer
- :tuple: Return a 2 integer tuple [seconds, nanoseconds]

../janet/src/core/os.c (1753:1)

## os/compiler

cfunction

(os/compiler)
Get the compiler used to compile the interpreter. Returns one of:
* :gcc
* :clang
* :msvc
* :kencc
* :unknown

../janet/src/core/os.c (255:1)

## os/cpu-count

cfunction

(os/cpu-count &opt dflt)
Get an approximate number of CPUs available on for this process to use. If unable to get an approximation, will return a default value dflt.

../janet/src/core/os.c (312:1)

## os/cryptorand

cfunction

(os/cryptorand n &opt buf)
Get or append `n` bytes of good quality random data provided by the OS. Returns a new buffer or `buf`.

../janet/src/core/os.c (1855:1)

## os/cwd

cfunction

(os/cwd)
Returns the current working directory.

../janet/src/core/os.c (1839:1)

## os/date

cfunction

(os/date &opt time local)
Returns the given time as a date struct, or the current time if `time` is not given. Date is given in UTC unless `local` is truthy, in which case the date is formatted for the local timezone. Returns a struct with following key values. Note that all numbers are 0-indexed.
* :seconds - number of seconds [0-61]
* :minutes - number of minutes [0-59]
* :hours - number of hours [0-23]
* :month-day - day of month [0-30]
* :month - month of year [0, 11]
* :year - years since year 0 (e.g. 2019)
* :week-day - day of the week [0-6]
* :year-day - day of the year [0-365]
* :dst - if Day Light Savings is in effect
You can set local timezone by setting TZ environment variable. See tzset(<time.h>) or _tzset(<time.h>) for further details.

../janet/src/core/os.c (1917:1)

## os/dir

cfunction

(os/dir dir &opt array)
Iterate over files and subdirectories in a directory. Returns an array of paths parts, with only the file name or directory name and no prefix.

../janet/src/core/os.c (2595:1)

## os/environ

cfunction

(os/environ)
Get a copy of the OS environment table.

../janet/src/core/os.c (1666:1)

## os/execute

cfunction

(os/execute args &opt flags env)
Execute a program on the system and return the exit code. `args` is an array/tuple of strings. The first string is the name of the program and the remainder are arguments passed to the program. `flags` is a keyword made from the following characters that modifies how the program executes:
* :e - enables passing an environment to the program. Without 'e', the current environment is inherited.
* :p - allows searching the current PATH for the program to execute. Without this flag, the first element of `args` must be an absolute path.
* :x - raises error if exit code is non-zero.
* :d - prevents the garbage collector terminating the program (if still running) and calling the equivalent of `os/proc-wait` (allows zombie processes).
`env` is a table/struct mapping environment variables to values. It can also contain the keys :in, :out, and :err, which allow redirecting stdio in the subprocess. :in, :out, and :err should be core/file or core/stream values. If core/stream values are used, the caller is responsible for ensuring pipes do not cause the program to block and deadlock.

../janet/src/core/os.c (1512:1)

## os/exit

cfunction

(os/exit &opt x force)
Exit from janet with an exit code equal to x. If x is not an integer, the exit with status equal the hash of x. If `force` is truthy will exit immediately and skip cleanup code.

../janet/src/core/os.c (281:1)

## os/getenv

cfunction

(os/getenv variable &opt dflt)
Get the string value of an environment variable.

../janet/src/core/os.c (1699:1)

## os/getpid

cfunction

(os/getpid)
Get the process ID of the current process.

../janet/src/core/os.c (870:1)

## os/isatty

cfunction

(os/isatty &opt file)
Returns true if `file` is a terminal. If `file` is not specified, it will default to standard output.

../janet/src/core/os.c (1822:1)

## os/link

cfunction

(os/link oldpath newpath &opt symlink)
Create a link at newpath that points to oldpath and returns nil. Iff symlink is truthy, creates a symlink. Iff symlink is falsey or not provided, creates a hard link. Does not work on Windows or Plan 9.

../janet/src/core/os.c (2129:1)

## os/lstat

cfunction

(os/lstat path &opt tab|key)
Like os/stat, but don't follow symlinks.

../janet/src/core/os.c (2550:1)

## os/mkdir

cfunction

(os/mkdir path)
Create a new directory. The path will be relative to the current directory if relative, otherwise it will be an absolute path. Returns true if the directory was created, false if the directory already exists, and errors otherwise.

../janet/src/core/os.c (2170:1)

## os/mktime

cfunction

(os/mktime date-struct &opt local)
Get the broken down date-struct time expressed as the number of seconds since January 1, 1970, the Unix epoch. Returns a real number. Date is given in UTC unless `local` is truthy, in which case the date is computed for the local timezone.
Inverse function to os/date.

../janet/src/core/os.c (2037:1)

## os/open

cfunction

(os/open path &opt flags mode)
Create a stream from a file, like the POSIX open system call. Returns a new stream. `mode` should be a file mode as passed to `os/chmod`, but only if the create flag is given. The default mode is 8r666. Allowed flags are as follows:
* :r - open this file for reading
* :w - open this file for writing
* :c - create a new file (O\_CREATE)
* :e - fail if the file exists (O\_EXCL)
* :t - shorten an existing file to length 0 (O\_TRUNC)
* :a - append to a file (O\_APPEND on posix, FILE_APPEND_DATA on windows)
Posix-only flags:
* :x - O\_SYNC
* :C - O\_NOCTTY
* :N - Turn off O\_NONBLOCK and disable ev reading/writing
Windows-only flags:
* :R - share reads (FILE\_SHARE\_READ)
* :W - share writes (FILE\_SHARE\_WRITE)
* :D - share deletes (FILE\_SHARE\_DELETE)
* :H - FILE\_ATTRIBUTE\_HIDDEN
* :O - FILE\_ATTRIBUTE\_READONLY
* :F - FILE\_ATTRIBUTE\_OFFLINE
* :T - FILE\_ATTRIBUTE\_TEMPORARY
* :d - FILE\_FLAG\_DELETE\_ON\_CLOSE
* :V - Turn off FILE\_FLAG\_OVERLAPPED and disable ev reading/writing
* :I - set bInheritHandle on the created file so it can be passed to other processes.
* :b - FILE\_FLAG\_NO\_BUFFERING

../janet/src/core/os.c (2716:1)

## os/perm-int

cfunction

(os/perm-int bytes)
Parse a 9-character permission string and return an integer that can be used by chmod.

../janet/src/core/os.c (2698:1)

## os/perm-string

cfunction

(os/perm-string int)
Convert a Unix octal permission value from a permission integer as returned by `os/stat` to a human readable string, that follows the formatting of Unix tools like `ls`. Returns the string as a 9-character string of r, w, x and - characters. Does not include the file/directory/symlink character as rendered by `ls`.

../janet/src/core/os.c (2688:1)

## os/pipe

cfunction

(os/pipe &opt flags)
Create a readable stream and a writable stream that are connected. Returns a two-element tuple where the first element is a readable stream and the second element is the writable stream. `flags` is a keyword set of flags to disable non-blocking settings on the ends of the pipe. This may be desired if passing the pipe to a subprocess with `os/spawn`.
* :W - sets the writable end of the pipe to a blocking stream.
* :R - sets the readable end of the pipe to a blocking stream.
By default, both ends of the pipe are non-blocking for use with the `ev` module.

../janet/src/core/os.c (2937:1)

## os/posix-chroot

cfunction

(os/posix-chroot dirname)
Call `chroot` to change the root directory to `dirname`. Not supported on all systems (POSIX only).

../janet/src/core/os.c (1599:1)

## os/posix-exec

cfunction

(os/posix-exec args &opt flags env)
Use the execvpe or execve system calls to replace the current process with an interface similar to os/execute. However, instead of creating a subprocess, the current process is replaced. Is not supported on Windows, and does not allow redirection of stdio.

../janet/src/core/os.c (1553:1)

## os/posix-fork

cfunction

(os/posix-fork)
Make a `fork` system call and create a new process. Return nil if in the new process, otherwise a core/process object (as returned by os/spawn). Not supported on all systems (POSIX and Plan 9 only).

../janet/src/core/os.c (1567:1)

## os/proc-close

cfunction

(os/proc-close proc)
Close pipes created for subprocess `proc` by `os/spawn` if they have not been closed. Then, if `proc` is not being waited for, wait. If this function waits, when `proc` completes, return the exit code of `proc`. Otherwise, return nil.

../janet/src/core/os.c (843:1)

## os/proc-kill

cfunction

(os/proc-kill proc &opt wait signal)
Kill the subprocess `proc` by sending SIGKILL to it on POSIX systems, or by closing the process handle on Windows. If `proc` has already completed, raise an error. If `wait` is truthy, will wait for `proc` to complete and return the exit code (this will raise an error if `proc` is being waited for). Otherwise, return `proc`. If `signal` is provided, send it instead of SIGKILL. Signal keywords are named after their C counterparts but in lowercase with the leading SIG stripped. `signal` is ignored on Windows.

../janet/src/core/os.c (799:1)

## os/proc-wait

cfunction

(os/proc-wait proc)
Suspend the current fiber until the subprocess `proc` completes. Once `proc` completes, return the exit code of `proc`. If called more than once on the same core/process value, will raise an error. When creating subprocesses using `os/spawn`, this function should be called on the returned value to avoid zombie processes.

../janet/src/core/os.c (686:1)

## os/readlink

cfunction

(os/readlink path)
Read the contents of a symbolic link. Does not work on Windows.

../janet/src/core/os.c (2256:1)

## os/realpath

cfunction

(os/realpath path)
Get the absolute path for a given path, following ../, ./, and symlinks. Returns an absolute path as a string.

../janet/src/core/os.c (2658:1)

## os/rename

cfunction

(os/rename oldname newname)
Rename a file on disk to a new path. Returns nil.

../janet/src/core/os.c (2644:1)

## os/rm

cfunction

(os/rm path)
Delete a file. Returns nil.

../janet/src/core/os.c (2244:1)

## os/rmdir

cfunction

(os/rmdir path)
Delete a directory. The directory must be empty to succeed.

../janet/src/core/os.c (2188:1)

## os/setenv

cfunction

(os/setenv variable value)
Set an environment variable.

../janet/src/core/os.c (1716:1)

## os/setlocale

cfunction

(os/setlocale &opt locale category)
Set the system locale, which affects how dates and numbers are formatted. Passing nil to locale will return the current locale. Category can be one of:
* :all (default)
* :collate
* :ctype
* :monetary
* :numeric
* :time
Returns the new locale if set successfully, otherwise nil. Note that this will affect other functions such as `os/strftime` and even `printf`.

../janet/src/core/os.c (2090:1)

## os/shell

cfunction

(os/shell str)
Pass a command string `str` directly to the system shell. Prefer `os/execute` in most cases.

../janet/src/core/os.c (1637:1)

## os/sigaction

cfunction

(os/sigaction which &opt handler interrupt-interpreter)
Add a signal handler for a given action. Use nil for the `handler` argument to remove a signal handler. All signal handlers are the same as supported by `os/proc-kill`.

../janet/src/core/os.c (941:1)

## os/sleep

cfunction

(os/sleep n)
Suspend the program for `n` seconds. `n` can be a real number. Returns nil.

../janet/src/core/os.c (1801:1)

## os/spawn

cfunction

(os/spawn args &opt flags env)
Execute a program on the system and return a core/process value representing the spawned subprocess. Takes the same arguments as `os/execute` but does not wait for the subprocess to complete. Unlike `os/execute`, the value `:pipe` can be used for :in, :out and :err keys in `env`. If used, the returned core/process will have a writable stream in the :in field and readable streams in the :out and :err fields. On non-Windows systems, the subprocess PID will be in the :pid field. The caller is responsible for waiting on the process (e.g. by calling `os/proc-wait` on the returned core/process value) to avoid creating zombie process. After the subprocess completes, the exit value is in the :return-code field. If `flags` includes 'x', a non-zero exit code will cause a waiting fiber to raise an error. The use of `:pipe` may fail if there are too many active file descriptors. The caller is responsible for closing pipes created by `:pipe` (either individually or using `os/proc-close`). Similar to `os/execute`, the caller is responsible for ensuring pipes do not cause the program to block and deadlock. As a special case, the stream passed to `:err` can be the keyword `:out` to redirect stderr to stdout in the subprocess.

../janet/src/core/os.c (1533:1)

## os/stat

cfunction

(os/stat path &opt tab|key)
Gets information about a file or directory. Returns a table unless the second argument is a keyword, in which case it returns only that field/value from stat. If the file or directory does not exist, returns nil.The keys are:
* :dev - the device that the file is on
* :mode - the type of file, one of :file, :directory, :block, :character, :fifo, :socket, :link, or :other
* :int-permissions - A Unix permission integer like 8r744
* :permissions - A Unix permission string like "rwxr--r--"
* :uid - File uid
* :gid - File gid
* :nlink - number of links to file
* :rdev - Real device of file. 0 on Windows
* :size - size of file in bytes
* :blocks - number of blocks in file. 0 on Windows
* :blocksize - size of blocks in file. 0 on Windows
* :accessed - timestamp when file last accessed
* :changed - timestamp when file last changed (permissions changed)
* :modified - timestamp when file last modified (content changed)

../janet/src/core/os.c (2528:1)

## os/strftime

cfunction

(os/strftime fmt &opt time local)
Format the given time as a string, or the current time if `time` is not given. The time is formatted according to the same rules as the ISO C89 function strftime(). The time is formatted in UTC unless `local` is truthy, in which case the date is formatted for the local timezone. You can set local timezone by setting TZ environment variable. See tzset(<time.h>) or _tzset(<time.h>) for further details.

../janet/src/core/os.c (1952:1)

## os/symlink

cfunction

(os/symlink oldpath newpath)
Create a symlink from oldpath to newpath, returning nil. Same as `(os/link oldpath newpath true)`.

../janet/src/core/os.c (2150:1)

## os/time

cfunction

(os/time)
Get the current time expressed as the number of whole seconds since January 1, 1970, the Unix epoch. Returns a real number.

../janet/src/core/os.c (1743:1)

## os/touch

cfunction

(os/touch path &opt actime modtime)
Update the access time and modification times for a file. By default, sets times to the current time.

../janet/src/core/os.c (2220:1)

## os/umask

cfunction

(os/umask mask)
Set a new umask, returns the old umask.

../janet/src/core/os.c (2580:1)

## os/which

cfunction

(os/which &opt test)
Check the current operating system. If `test` is nil or unset, Returns one of:
* :windows
* :mingw
* :cygwin
* :macos
* :web - Web assembly (emscripten)
* :linux
* :hurd
* :freebsd
* :openbsd
* :netbsd
* :dragonfly
* :bsd
* :posix - A POSIX compatible system (default)
May also return a custom keyword specified at build time. Is `test` is truthy, will check if the current operating system equals `test` and return true if they are the same, false otherwise.

../janet/src/core/os.c (150:1)

## pairs

function

(pairs x)
Return an array of tuples of the key-value pairs of `x`. For bytes
and indexed types, the integer indices are considered the keys.
`x` can be a bytes, indexed, dictionary, or abstract type with
suitable `get` and `in` methods.

boot.janet (1955:1)

## parse

function

(parse str)
Parse a string and return the first value. For complex parsing, such as for a repl with error handling,
use the parser api.

boot.janet (3070:1)

## parse-all

function

(parse-all str)
Parse a string and return all parsed values. For complex parsing, such as for a repl with error handling,
use the parser api.

boot.janet (3085:1)

## parser/byte

cfunction

(parser/byte parser b)
Input a single byte `b` into the parser byte stream. Returns the parser.

../janet/src/core/parse.c (1000:1)

## parser/clone

cfunction

(parser/clone p)
Creates a deep clone of a parser that is identical to the input parser. This cloned parser can be used to continue parsing from a good checkpoint if parsing later fails. Returns a new parser.

../janet/src/core/parse.c (1269:1)

## parser/consume

cfunction

(parser/consume parser bytes &opt index)
Input bytes into the parser and parse them. Will not throw errors if there is a parse error. Starts at the byte index given by `index`. Returns the number of bytes read.

../janet/src/core/parse.c (911:1)

## parser/eof

cfunction

(parser/eof parser)
Indicate to the parser that the end of file was reached. This puts the parser in the :dead state.

../janet/src/core/parse.c (940:1)

## parser/error

cfunction

(parser/error parser)
If the parser is in the error state, returns the message associated with that error. Otherwise, returns nil. Also flushes the parser state and parser queue, so be sure to handle everything in the queue before calling `parser/error`.

../janet/src/core/parse.c (1037:1)

## parser/flush

cfunction

(parser/flush parser)
Clears the parser state and parse queue. Can be used to reset the parser if an error was encountered. Does not reset the line and column counter, so to begin parsing in a new context, create a new parser.

../janet/src/core/parse.c (1070:1)

## parser/has-more

cfunction

(parser/has-more parser)
Check if the parser has more values in the value queue.

../janet/src/core/parse.c (992:1)

## parser/insert

cfunction

(parser/insert parser value)
Insert a value into the parser. This means that the parser state can be manipulated in between chunks of bytes. This would allow a user to add extra elements to arrays and tuples, for example. Returns the parser.

../janet/src/core/parse.c (949:1)

## parser/new

cfunction

(parser/new)
Creates and returns a new parser object. Parsers are state machines that can receive bytes and generate a stream of values.

../janet/src/core/parse.c (900:1)

## parser/produce

cfunction

(parser/produce parser &opt wrap)
Dequeue the next value in the parse queue. Will return nil if no parsed values are in the queue, otherwise will dequeue the next value. If `wrap` is truthy, will return a 1-element tuple that wraps the result. This tuple can be used for source-mapping purposes.

../janet/src/core/parse.c (1054:1)

## parser/state

cfunction

(parser/state parser &opt key)
Returns a representation of the internal state of the parser. If a key is passed, only that information about the state is returned. Allowed keys are:
* :delimiters - Each byte in the string represents a nested data structure. For example, if the parser state is '(["', then the parser is in the middle of parsing a string inside of square brackets inside parentheses. Can be used to augment a REPL prompt.
* :frames - Each table in the array represents a 'frame' in the parser state. Frames contain information about the start of the expression being parsed as well as the type of that expression and some type-specific information.

../janet/src/core/parse.c (1232:1)

## parser/status

cfunction

(parser/status parser)
Gets the current status of the parser state machine. The status will be one of:
* :pending - a value is being parsed.
* :error - a parsing error was encountered.
* :root - the parser can either read more values or safely terminate.

../janet/src/core/parse.c (1010:1)

## parser/where

cfunction

(parser/where parser &opt line col)
Returns the current line number and column of the parser's internal state. If line is provided, the current line number of the parser is first set to that value. If column is also provided, the current column number of the parser is also first set to that value.

../janet/src/core/parse.c (1081:1)

## partial

function

(partial f & more)
Partial function application.

boot.janet (1702:1)

## partition

function

(partition n x)
Partition the values of `x` into tuples of size `n`. Returns a new
array.
`n` should be a non-negative integer.
`x` can be a bytes, indexed, fiber, or abstract type with suitable
`get` and `next` methods.

boot.janet (2127:1)

## partition-by

function

(partition-by f x)
Partition values of `x` by a function `f`. Partitions split when `f`
applied to a value changes result when iterating to the next value
of `x`. Returns a new array of arrays.
`x` can be a bytes, indexed, fiber, or abstract type with suitable
`get` and `next` methods.

boot.janet (2007:1)

## peg/compile

cfunction

(peg/compile peg)
Compiles a peg source data structure into a <core/peg>. This will speed up matching if the same peg will be used multiple times. `(dyn :peg-grammar)` replaces `default-peg-grammar` for the grammar of the peg.

../janet/src/core/peg.c (1921:1)

## peg/find

cfunction

(peg/find peg text &opt start & args)
Find first index where the peg matches in text. Returns an integer, or nil if not found.

../janet/src/core/peg.c (2000:1)

## peg/find-all

cfunction

(peg/find-all peg text &opt start & args)
Find all indexes where the peg matches in text. Returns an array of integers.

../janet/src/core/peg.c (2012:1)

## peg/match

cfunction

(peg/match peg text &opt start & args)
Match a Parsing Expression Grammar to a byte string and return an array of captured values. Returns nil if text does not match the language defined by peg. The syntax of PEGs is documented on the Janet website.

../janet/src/core/peg.c (1991:1)

## peg/replace

cfunction

(peg/replace peg subst text &opt start & args)
Replace first match of `peg` in `text` with `subst`, returning a new buffer. The peg does not need to make captures to do replacement. If `subst` is a function, it will be called with the matching text followed by any captures. If no matches are found, returns the input string in a new buffer.

../janet/src/core/peg.c (2063:1)

## peg/replace-all

cfunction

(peg/replace-all peg subst text &opt start & args)
Replace all matches of `peg` in `text` with `subst`, returning a new buffer. The peg does not need to make captures to do replacement. If `subst` is a function, it will be called with the matching text followed by any captures.

../janet/src/core/peg.c (2054:1)

## pos?

function

(pos? x)
Check if x is greater than 0.

boot.janet (987:1)

## postwalk

function

(postwalk f form)
Do a post-order traversal of a data structure and call `(f x)`
on every visitation.

boot.janet (1632:1)

## pp

function

(pp x)
Pretty-print to stdout or `(dyn *out*)`. The format string used is `(dyn *pretty-format* "%q")`.

boot.janet (2174:1)

## prewalk

function

(prewalk f form)
Similar to `postwalk`, but do pre-order traversal.

boot.janet (1638:1)

## prin

cfunction

(prin & xs)
Same as `print`, but does not add trailing newline.

../janet/src/core/io.c (570:1)

## prinf

cfunction

(prinf fmt & xs)
Like `printf` but with no trailing newline.

../janet/src/core/io.c (676:1)

## print

cfunction

(print & xs)
Print values to the console (standard out). Value are converted to strings if they are not already. After printing all values, a newline character is printed. Use the value of `(dyn :out stdout)` to determine what to push characters to. Expects `(dyn :out stdout)` to be either a core/file or a buffer. Returns nil.

../janet/src/core/io.c (560:1)

## printf

cfunction

(printf fmt & xs)
Prints output formatted as if with `(string/format fmt ;xs)` to `(dyn :out stdout)` with a trailing newline.

../janet/src/core/io.c (670:1)

## product

function

(product x)
Returns the product of the values of `x`. If `x` is empty, returns
1.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type
with suitable `get` and `next` methods.

boot.janet (818:1)

## prompt

macro

(prompt tag & body)
Set up a checkpoint that can be returned to. `tag` should be a value
that is used in a `return` statement, like a keyword.

boot.janet (402:1)

## propagate

function

(propagate x fiber)
Propagate a signal from a fiber to the current fiber and set the last value of the current fiber to `x`. The signal value is then available as the status of the current fiber. The resulting stack trace from the current fiber will include frames from fiber. If fiber is in a state that can be resumed, resuming the current fiber will first resume `fiber`. This function can be used to re-raise an error without losing the original stack trace.

## protect

macro

(protect & body)
Evaluate expressions, while capturing any errors. Evaluates to a tuple
of two elements. The first element is true if successful, false if an
error, and the second is the return value or error.

boot.janet (295:1)

## put

function

(put x key val)
Associate `key` with `val` for mutable `x`. Arrays and buffers only accept non-negative integer keys, and will expand if an out of bounds value is provided. For an array, extra space will be filled with `nil`s, while for buffers, 0 bytes are used instead. For a table, putting a key that is in the table prototype will hide the association defined by the prototype, but will not mutate the prototype table. Putting a `nil` value into a table will remove the table's corresponding association. Returns `x`.

## put-in

function

(put-in x ks v)
Use the keys `ks` to put a value `v` into a nested spot in
`x`. Missing spots will be replaced with tables. Returns `x`
modified.
`x` can be a suitable array, table or abstract type with `get` and
`put` methods.
`ks` can be an indexed or abstract type with suitable `get` and
`length` methods.

boot.janet (1852:1)

## quit

function

(quit &opt value)
Tries to exit from the current repl or run-context. Does not always exit the application.
Works by setting the :exit dynamic binding to true. Passing a non-nil `value` here will cause the outer
run-context to return that value.

boot.janet (3052:1)

## range

cfunction

(range & args)
Create an array of values [start, end) with a given step. With one argument, returns a range [0, end). With two arguments, returns a range [start, end). With three, returns a range with optional step size.

../janet/src/core/corelib.c (433:1)

## reduce

function

(reduce f init x)
Also know as fold-left in many languages, this function transforms
`x` by successively applying a function `f` to values from `x` and
an updating "accumulator" value. `f` is a function of 2 arguments,
`(f acc v)`, where `acc` starts as `init` and `v` is the next value
in `x`. `f` returns a value that will be used as `acc` in the next
call to `f`. The ultimate return value is that of the final call to
`f`.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type
with suitable `get` and `next` methods.

boot.janet (1079:1)

## reduce2

function

(reduce2 f x)
The 2-argument version of `reduce`. Instead of taking an explicit
initial value, the first value of `x` is used instead. If `x` is
empty, returns `nil`.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type
with suitable `get` and `next` methods.

boot.janet (1097:1)

## repeat

macro

(repeat n & body)
Evaluate body n times. If n is negative, body will be evaluated 0 times. Evaluates to nil.

boot.janet (633:1)

## repl

function

(repl &opt chunks onsignal env parser read)
Run a repl. The first parameter is an optional function to call to
get a chunk of source code that should return nil for end of file.
The second parameter is a function that is called when a signal is
caught. One can provide an optional environment table to run
the repl in, as well as an optional parser or read function to pass
to `run-context`.

boot.janet (4127:1)

## require

function

(require path & args)
Require a module with the given name. Will search all of the paths in
`module/paths`. Returns the new environment
returned from compiling and running the file.

boot.janet (3484:1)

## resume

function

(resume fiber &opt x)
Resume a new or suspended fiber and optionally pass in a value to the fiber that will be returned to the last yield in the case of a pending fiber, or the argument to the dispatch function in the case of a new fiber. Returns either the return result of the fiber's dispatch function, or the value from the next yield call in fiber.

## return

function

(return to &opt value)
Return to a prompt point.

boot.janet (430:1)

## reverse

function

(reverse x)
Reverses the order of the values in `x`. If `x` is a bytes type,
returns a buffer, otherwise returns an array.
`x` can be a bytes, indexed, fiber, or abstract type with suitable
`get` and `next` methods.

boot.janet (1755:1)

## reverse!

function

(reverse! x)
Reverses the order of the values in `x` and returns it mutated.
`x` can be a buffer, array, or abstract type with suitable
`get`, `length`, and `put` methods.

boot.janet (1738:1)

## root-env

table

The root environment used to create environments with (make-env).

## run-context

function

(run-context opts)
Run a context. This evaluates expressions in an environment,
and encapsulates the parsing, compilation, and evaluation.
Returns `(in environment :exit-value environment)` when complete.
`opts` is a table or struct of options. The options are as follows:
* `:chunks` -- callback to read into a buffer - default is getline
* `:on-parse-error` -- callback when parsing fails - default is bad-parse
* `:env` -- the environment to compile against - default is the current env
* `:source` -- source path for better errors (use keywords for non-paths) - default
is `:<anonymous>`
* `:on-compile-error` -- callback when compilation fails - default is bad-compile
* `:on-compile-warning` -- callback for any linting error - default is warn-compile
* `:evaluator` -- callback that executes thunks. Signature is (evaluator thunk source
env where)
* `:on-status` -- callback when a value is evaluated - default is debug/stacktrace.
* `:fiber-flags` -- what flags to wrap the compilation fiber with. Default is :ia.
* `:expander` -- an optional function that is called on each top level form before
being compiled.
* `:parser` -- provide a custom parser that implements the same interface as Janet's
built-in parser.
* `:read` -- optional function to get the next form, called like `(read env source)`.
Overrides all parsing.

boot.janet (2879:1)

## sandbox

cfunction

(sandbox & forbidden-capabilities)
Disable feature sets to prevent the interpreter from using certain system resources. Once a feature is disabled, there is no way to re-enable it. Capabilities can be:
* :all - disallow all (except IO to stdout, stderr, and stdin)
* :asm - disallow calling `asm` and `disasm` functions.
* :chroot - disallow calling `os/posix-chroot`
* :compile - disallow calling `compile`. This will disable a lot of functionality, such as `eval`.
* :env - disallow reading and write env variables
* :exit - disallow calling `os/exit` or otherwise early exiting the process in trivial ways.
* :ffi - disallow FFI (recommended if disabling anything else)
* :ffi-define - disallow loading new FFI modules and binding new functions
* :ffi-jit - disallow calling `ffi/jitfn`
* :ffi-use - disallow using any previously bound FFI functions and memory-unsafe functions.
* :fs - disallow access to the file system
* :fs-read - disallow read access to the file system
* :fs-temp - disallow creating temporary files
* :fs-write - disallow write access to the file system
* :hrtime - disallow high-resolution timers
* :locale - disallow `os/setlocale`
* :modules - disallow load dynamic modules (natives)
* :net - disallow network access
* :net-connect - disallow making outbound network connections
* :net-listen - disallow accepting inbound network connections
* :sandbox - disallow calling this function
* :signal - disallow adding or removing signal handlers
* :subprocess - disallow running subprocesses
* :threads - disallow spawning threads with `ev/thread`. Certain helper threads may still be spawned.
* :unmarshal - disallow calling the `unmarshal` function.

../janet/src/core/corelib.c (786:1)

## scan-number

cfunction

(scan-number str &opt base)
Parse a number from a byte sequence and return that number, either an integer or a real. The number must be in the same format as numbers in janet source code. Will return nil on an invalid number. Optionally provide a base - if a base is provided, no radix specifier is expected at the beginning of the number.

../janet/src/core/corelib.c (381:1)

## seq

macro

(seq head & body)
Similar to `loop`, but accumulates the loop body into an array and returns that.
See `loop` for details.

boot.janet (732:1)

## setdyn

cfunction

(setdyn key value)
Set a dynamic binding. Returns value.

../janet/src/core/corelib.c (278:1)

## short-fn

macro

(short-fn arg &opt name)
Shorthand for `fn`. Arguments are given as `$n`, where `n` is the
0-indexed argument of the function. `$` is also an alias for the
first (index 0) argument. The `$&` symbol will make the anonymous
function variadic if it appears in the body of the function, and
can be combined with positional arguments.

boot.janet (2700:1)

## signal

cfunction

(signal what x)
Raise a signal with payload x. `what` can be an integer
from 0 through 7 indicating user(0-7), or one of:
* :ok
* :error
* :debug
* :yield
* :user(0-7)
* :interrupt
* :await

../janet/src/core/corelib.c (705:1)

## slice

cfunction

(slice x &opt start end)
Extract a sub-range of an indexed data structure or byte sequence.

../janet/src/core/corelib.c (416:1)

## slurp

function

(slurp path)
Read all data from a file with name `path` and then close the file.

boot.janet (2149:1)

## some

function

(some pred x & xs)
Returns `nil` if applying `pred` to every value in `x` results in
only falsey values, otherwise returns the first truthy result
encountered.
Also functions variadically, i.e. takes additional arguments, with
suitable changes to the arity of `f`. `f` is called with both values
from `x` and additional arguments, and only as many times as the
length of the shortest of `x` and each element of `xs`. If `x` or
any element of `xs` is empty, returns `nil`.
`x` and elements of `xs` can be values of type bytes, indexed,
dictionary, fiber, or abstract with suitable `get` and `next`
methods.

boot.janet (2538:1)

## sort

function

(sort x &opt before?)
Sorts `x` in-place, and returns it. Uses quick-sort and is not a
stable sort. If a `before?` comparator function is provided, sorts
elements using that, otherwise uses `<`.
`x` can be a buffer, array, or abstract type with suitable `get`,
`put`, and `length` methods.

boot.janet (1037:1)

## sort-by

function

(sort-by f x)
Sorts `x` in-place by calling a function `f` on each element and
comparing the results with `<`.
`x` can be a buffer, array, or abstract type with suitable `get`,
`put`, and `length` methods.

boot.janet (1050:1)

## sorted

function

(sorted ind &opt before?)
Returns a new sorted array based on an indexed type `ind`. If a
`before?` comparator function is provided, sorts elements using
that, otherwise uses `<`.

boot.janet (1061:1)

## sorted-by

function

(sorted-by f ind)
Returns a new sorted array based on an indexed type `ind`.
Comparison is done by invoking a function `f` on each element and
comparing the results with `<`.

boot.janet (1070:1)

## spit

function

(spit path contents &opt mode)
Write `contents` to a file at `path`. Can optionally append to the file.

boot.janet (2158:1)

## stderr

core/file

The standard error file.

../janet/src/core/io.c (863:1)

## stdin

core/file

The standard input file.

../janet/src/core/io.c (867:1)

## stdout

core/file

The standard output file.

../janet/src/core/io.c (859:1)

## string

cfunction

(string & xs)
Creates a string by concatenating the elements of `xs` together. If an element is not a byte sequence, it is converted to bytes via `describe`. Returns the new string.

../janet/src/core/corelib.c (330:1)

## string/ascii-lower

cfunction

(string/ascii-lower str)
Returns a new string where all bytes are replaced with the lowercase version of themselves in ASCII. Does only a very simple case check, meaning no unicode support.

../janet/src/core/string.c (246:1)

## string/ascii-upper

cfunction

(string/ascii-upper str)
Returns a new string where all bytes are replaced with the uppercase version of themselves in ASCII. Does only a very simple case check, meaning no unicode support.

../janet/src/core/string.c (265:1)

## string/bytes

cfunction

(string/bytes str)
Returns a tuple of integers that are the byte values of the string.

../janet/src/core/string.c (220:1)

## string/check-set

cfunction

(string/check-set set str)
Checks that the string `str` only contains bytes that appear in the string `set`. Returns true if all bytes in `str` appear in `set`, false if some bytes in `str` do not appear in `set`.

../janet/src/core/string.c (467:1)

## string/find

cfunction

(string/find patt str &opt start-index)
Searches for the first instance of pattern `patt` in string `str`. Returns the index of the first character in `patt` if found, otherwise returns nil.

../janet/src/core/string.c (310:1)

## string/find-all

cfunction

(string/find-all patt str &opt start-index)
Searches for all instances of pattern `patt` in string `str`. Returns an array of all indices of found patterns. Overlapping instances of the pattern are counted individually, meaning a byte in `str` may contribute to multiple found patterns.

../janet/src/core/string.c (349:1)

## string/format

cfunction

(string/format format & values)
Similar to C's `snprintf`, but specialized for operating with Janet values. Returns a new string.
The following conversion specifiers are supported, where the upper case specifiers generate upper case output:
- `c`: ASCII character.
- `d`, `i`: integer, formatted as a decimal number.
- `x`, `X`: integer, formatted as a hexadecimal number.
- `o`: integer, formatted as an octal number.
- `f`, `F`: floating point number, formatted as a decimal number.
- `e`, `E`: floating point number, formatted in scientific notation.
- `g`, `G`: floating point number, formatted in its shortest form.
- `a`, `A`: floating point number, formatted as a hexadecimal number.
- `s`: formatted as a string, precision indicates padding and maximum length.
- `t`: emit the type of the given value.
- `v`: format with (describe x)
- `V`: format with (string x)
- `j`: format to jdn (Janet data notation).
The following conversion specifiers are used for "pretty-printing", where the upper-case variants generate colored output. These specifiers can take a precision argument to specify the maximum nesting depth to print. The multiline specifiers can also take a width argument, which defaults to 80 columns.
- `p`, `P`: pretty format, truncating if necessary
- `m`, `M`: pretty format without truncating.
- `q`, `Q`: pretty format on one line, truncating if necessary.
- `n`, `N`: pretty format on one line without truncation.

../janet/src/core/string.c (536:1)

## string/from-bytes

cfunction

(string/from-bytes & byte-vals)
Creates a string from integer parameters with byte values. All integers will be coerced to the range of 1 byte 0-255.

../janet/src/core/string.c (233:1)

## string/has-prefix?

cfunction

(string/has-prefix? pfx str)
Tests whether `str` starts with `pfx`.

../janet/src/core/string.c (325:1)

## string/has-suffix?

cfunction

(string/has-suffix? sfx str)
Tests whether `str` ends with `sfx`.

../janet/src/core/string.c (336:1)

## string/join

cfunction

(string/join parts &opt sep)
Joins an array of strings into one string, optionally separated by a separator string `sep`.

../janet/src/core/string.c (493:1)

## string/repeat

cfunction

(string/repeat bytes n)
Returns a string that is `n` copies of `bytes` concatenated.

../janet/src/core/string.c (202:1)

## string/replace

cfunction

(string/replace patt subst str)
Replace the first occurrence of `patt` with `subst` in the string `str`. If `subst` is a function, it will be called with `patt` only if a match is found, and should return the actual replacement text to use. Will return the new string if `patt` is found, otherwise returns `str`.

../janet/src/core/string.c (386:1)

## string/replace-all

cfunction

(string/replace-all patt subst str)
Replace all instances of `patt` with `subst` in the string `str`. Overlapping matches will not be counted, only the first match in such a span will be replaced. If `subst` is a function, it will be called with `patt` once for each match, and should return the actual replacement text to use. Will return the new string if `patt` is found, otherwise returns `str`.

../janet/src/core/string.c (412:1)

## string/reverse

cfunction

(string/reverse str)
Returns a string that is the reversed version of `str`.

../janet/src/core/string.c (284:1)

## string/slice

cfunction

(string/slice bytes &opt start end)
Returns a substring from a byte sequence. The substring is from index `start` inclusive to index `end`, exclusive. All indexing is from 0. `start` and `end` can also be negative to indicate indexing from the end of the string. Note that if `start` is negative it is exclusive, and if `end` is negative it is inclusive, to allow a full negative slice range.

../janet/src/core/string.c (173:1)

## string/split

cfunction

(string/split delim str &opt start limit)
Splits a string `str` with delimiter `delim` and returns an array of substrings. The substrings will not contain the delimiter `delim`. If `delim` is not found, the returned array will have one element. Will start searching for `delim` at the index `start` (if provided), and return up to a maximum of `limit` results (if provided).

../janet/src/core/string.c (439:1)

## string/trim

cfunction

(string/trim str &opt set)
Trim leading and trailing whitespace from a byte sequence. If the argument `set` is provided, consider only characters in `set` to be whitespace.

../janet/src/core/string.c (604:1)

## string/triml

cfunction

(string/triml str &opt set)
Trim leading whitespace from a byte sequence. If the argument `set` is provided, consider only characters in `set` to be whitespace.

../janet/src/core/string.c (617:1)

## string/trimr

cfunction

(string/trimr str &opt set)
Trim trailing whitespace from a byte sequence. If the argument `set` is provided, consider only characters in `set` to be whitespace.

../janet/src/core/string.c (627:1)

## string?

function

(string? x)
Check if x is a string.

boot.janet (102:1)

## struct

cfunction

(struct & kvs)
Create a new struct from a sequence of key value pairs. kvs is a sequence k1, v1, k2, v2, k3, v3, ... If kvs has an odd number of elements, an error will be thrown. Returns the new struct.

../janet/src/core/corelib.c (515:1)

## struct/getproto

cfunction

(struct/getproto st)
Return the prototype of a struct, or nil if it doesn't have one.

../janet/src/core/struct.c (223:1)

## struct/proto-flatten

cfunction

(struct/proto-flatten st)
Convert a struct with prototypes to a struct with no prototypes by merging all key value pairs from recursive prototypes into one new struct.

../janet/src/core/struct.c (233:1)

## struct/rawget

cfunction

(struct/rawget st key)
Gets a value from a struct `st` without looking at the prototype struct. If `st` does not contain the key directly, the function will return nil without checking the prototype. Returns the value in the struct.

../janet/src/core/struct.c (297:1)

## struct/to-table

cfunction

(struct/to-table st &opt recursive)
Convert a struct to a table. If recursive is true, also convert the table's prototypes into the new struct's prototypes as well.

../janet/src/core/struct.c (266:1)

## struct/with-proto

cfunction

(struct/with-proto proto & kvs)
Create a struct using the `proto` argument as the struct's prototype. `kvs` are as in the `struct` function.

../janet/src/core/struct.c (207:1)

## struct?

function

(struct? x)
Check if x is a struct.

boot.janet (109:1)

## sum

function

(sum x)
Returns the sum of the values of `x`. If `x` is empty, returns 0.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type with
suitable `get` and `next` methods.

boot.janet (772:1)

## symbol

cfunction

(symbol & xs)
Creates a symbol by concatenating the elements of `xs` together. If an element is not a byte sequence, it is converted to bytes via `describe`. Returns the new symbol.

../janet/src/core/corelib.c (341:1)

## symbol/slice

cfunction

(symbol/slice bytes &opt start end)
Same as string/slice, but returns a symbol.

../janet/src/core/string.c (186:1)

## symbol?

function

(symbol? x)
Check if x is a symbol.

boot.janet (103:1)

## table

cfunction

(table & kvs)
Creates a new table from a variadic number of keys and values. kvs is a sequence k1, v1, k2, v2, k3, v3, ... If kvs has an odd number of elements, an error will be thrown. Returns the new table.

../janet/src/core/corelib.c (480:1)

## table/clear

cfunction

(table/clear tab)
Remove all key-value pairs in a table and return the modified table `tab`.

../janet/src/core/table.c (419:1)

## table/clone

cfunction

(table/clone tab)
Create a copy of a table. Updates to the new table will not change the old table, and vice versa.

../janet/src/core/table.c (410:1)

## table/getproto

cfunction

(table/getproto tab)
Get the prototype table of a table. Returns nil if the table has no prototype, otherwise returns the prototype.

../janet/src/core/table.c (361:1)

## table/new

cfunction

(table/new capacity)
Creates a new empty table with pre-allocated memory for `capacity` entries. This means that if one knows the number of entries going into a table on creation, extra memory allocation can be avoided. Returns the new table.

../janet/src/core/table.c (322:1)

## table/proto-flatten

cfunction

(table/proto-flatten tab)
Create a new table that is the result of merging all prototypes into a new table.

../janet/src/core/table.c (428:1)

## table/rawget

cfunction

(table/rawget tab key)
Gets a value from a table `tab` without looking at the prototype table. If `tab` does not contain the key directly, the function will return nil without checking the prototype. Returns the value in the table.

../janet/src/core/table.c (400:1)

## table/setproto

cfunction

(table/setproto tab proto)
Set the prototype of a table. Returns the original table `tab`.

../janet/src/core/table.c (372:1)

## table/to-struct

cfunction

(table/to-struct tab &opt proto)
Return a struct based on a table `tab`. If given, the optional argument `proto` specifies the new struct's prototype. Note that if `proto` is not specified, the new struct will not have a prototype.

../janet/src/core/table.c (385:1)

## table/weak

cfunction

(table/weak capacity)
Creates a new empty table with weak references to keys and values. Similar to `table/new`. Returns the new table.

../janet/src/core/table.c (334:1)

## table/weak-keys

cfunction

(table/weak-keys capacity)
Creates a new empty table with weak references to keys and normal references to values. Similar to `table/new`. Returns the new table.

../janet/src/core/table.c (343:1)

## table/weak-values

cfunction

(table/weak-values capacity)
Creates a new empty table with normal references to keys and weak references to values. Similar to `table/new`. Returns the new table.

../janet/src/core/table.c (352:1)

## table?

function

(table? x)
Check if x is a table.

boot.janet (108:1)

## tabseq

macro

(tabseq head key-body & value-body)
Similar to `loop`, but accumulates key value pairs into a table.
See `loop` for details.

boot.janet (748:1)

## take

function

(take n ind)
Take the first n elements of a fiber, indexed or bytes type. Returns a new array, tuple or string,
respectively. If `n` is negative, takes the last `n` elements instead.

boot.janet (1354:1)

## take-until

function

(take-until pred ind)
Same as `(take-while (complement pred) ind)`.

boot.janet (1379:1)

## take-while

function

(take-while pred ind)
Given a predicate, take only elements from a fiber, indexed, or bytes type that satisfy
the predicate, and abort on first failure. Returns a new array, tuple, or string, respectively.

boot.janet (1388:1)

## thaw

function

(thaw ds)
Thaw an object (make it mutable) and do a deep copy, making
child values also mutable. Closures, fibers, and abstract
types will not be recursively thawed, but all other types will.

boot.janet (2586:1)

## thaw-keep-keys

function

(thaw-keep-keys ds)
Similar to `thaw`, but do not modify table or struct keys.

boot.janet (2601:1)

## toggle

macro

(toggle value)
Set a value to its boolean inverse. Same as `(set value (not value))`.

boot.janet (79:1)

## trace

cfunction

(trace func)
Enable tracing on a function. Returns the function.

../janet/src/core/corelib.c (644:1)

## tracev

macro

(tracev x)
Print to stderr a value and a description of the form that produced that value.
Evaluates to x.

boot.janet (1505:1)

## true?

function

(true? x)
Check if x is true.

boot.janet (114:1)

## truthy?

function

(truthy? x)
Check if x is truthy.

boot.janet (113:1)

## try

macro

(try body catch)
Try something and catch errors. `body` is any expression,
and `catch` should be a form, the first element of which is a tuple. This tuple
should contain a binding for errors and an optional binding for
the fiber wrapping the body. Returns the result of `body` if no error,
or the result of `catch` if an error.

boot.janet (341:1)

## tuple

cfunction

(tuple & items)
Creates a new tuple that contains items. Returns the new tuple.

../janet/src/core/corelib.c (401:1)

## tuple/brackets

cfunction

(tuple/brackets & xs)
Creates a new bracketed tuple containing the elements xs.

../janet/src/core/tuple.c (58:1)

## tuple/join

cfunction

(tuple/join & parts)
Create a tuple by joining together other tuples and arrays.

../janet/src/core/tuple.c (119:1)

## tuple/setmap

cfunction

(tuple/setmap tup line column)
Set the sourcemap metadata on a tuple. line and column indicate should be integers.

../janet/src/core/tuple.c (108:1)

## tuple/slice

cfunction

(tuple/slice arrtup [,start=0 [,end=(length arrtup)]])
Take a sub-sequence of an array or tuple from index `start` inclusive to index `end` exclusive. If `start` or `end` are not provided, they default to 0 and the length of `arrtup`, respectively. `start` and `end` can also be negative to indicate indexing from the end of the input. Note that if `start` is negative it is exclusive, and if `end` is negative it is inclusive, to allow a full negative slice range. Returns the new tuple.

../janet/src/core/tuple.c (66:1)

## tuple/sourcemap

cfunction

(tuple/sourcemap tup)
Returns the sourcemap metadata attached to a tuple, which is another tuple (line, column).

../janet/src/core/tuple.c (96:1)

## tuple/type

cfunction

(tuple/type tup)
Checks how the tuple was constructed. Will return the keyword :brackets if the tuple was parsed with brackets, and :parens otherwise. The two types of tuples will behave the same most of the time, but will print differently and be treated differently by the compiler.

../janet/src/core/tuple.c (80:1)

## tuple?

function

(tuple? x)
Check if x is a tuple.

boot.janet (111:1)

## type

cfunction

(type x)
Returns the type of `x` as a keyword. `x` is one of:
* :number
* :nil
* :boolean
* :fiber
* :string
* :symbol
* :keyword
* :array
* :tuple
* :table
* :struct
* :buffer
* :function
* :cfunction
* :pointer
or another keyword for an abstract type.

../janet/src/core/corelib.c (577:1)

## unless

macro

(unless condition & body)
Shorthand for `(when (not condition) ;body)`.

boot.janet (239:1)

## unmarshal

cfunction

(unmarshal buffer &opt lookup)
Unmarshal a value from a buffer. An optional lookup table can be provided to allow for aliases to be resolved. Returns the value unmarshalled from the buffer.

../janet/src/core/marsh.c (1708:1)

## untrace

cfunction

(untrace func)
Disables tracing on a function. Returns the function.

../janet/src/core/corelib.c (653:1)

## update

function

(update x key f & args)
For a given key in `x`, replace its associated value with the result
of applying `f` to that value. If `args` are provided, they will be
passed along to `f` as well. Returns updated `x`.
`x` can be a buffer, array, table, or suitable abstract type with
`get` and `put` methods.

boot.janet (1881:1)

## update-in

function

(update-in x ks f & args)
Update a value in `x`. Looks into a nested spot in `x` identified by
the keys `ks` and replaces the value found there with `f` applied to
that value and any values passed and available in `args`. Missing
spots will be replaced with tables and `f` is passed `nil` instead
of a found value. Returns `x` modified.
`x` can be a suitable array, table or abstract type with `get` and
`put` methods.
`ks` can be an indexed or abstract type with suitable `get` and
`length` methods.

boot.janet (1821:1)

## use

macro

(use & modules)
Similar to `import`, but imported bindings are not prefixed with a module
identifier. Can also import multiple modules in one shot.

boot.janet (3540:1)

## values

function

(values x)
Get the values of `x` as an array.
`x` can be a bytes, indexed, dictionary, fiber, or abstract type
with suitable `get` and `next` methods.

boot.janet (1937:1)

## var-

macro

(var- name & more)
Define a private var that will not be exported.

boot.janet (74:1)

## varfn

macro

(varfn name & body)
Create a function that can be rebound. `varfn` has the same signature
as `defn`, but defines functions in the environment as vars. If a var `name`
already exists in the environment, it is rebound to the new function. Returns
a function.

boot.janet (2668:1)

## varglobal

function

(varglobal name init)
Dynamically create a global var.

boot.janet (91:1)

## walk

function

(walk f form)
Iterate over the values in ast and apply `f`
to them. Collect the results in a data structure. If ast is not a
table, struct, array, or tuple,
returns form.

boot.janet (1619:1)

## warn-compile

function

(warn-compile msg level where &opt line col)
Default handler for a compile warning.

boot.janet (2832:1)

## when

macro

(when condition & body)
Evaluates the body when the condition is true. Otherwise returns nil.

boot.janet (234:1)

## when-let

macro

(when-let bindings & body)
Same as `(if-let bindings (do ;body))`.

boot.janet (831:1)

## when-with

macro

(when-with [binding ctor dtor] & body)
Similar to with, but if binding is false or nil, returns
nil without evaluating the body. Otherwise, the same as `with`.

boot.janet (470:1)

## with

macro

(with [binding ctor dtor] & body)
Evaluate `body` with some resource, which will be automatically cleaned up
if there is an error in `body`. `binding` is bound to the expression `ctor`, and
`dtor` is a function or callable that is passed the binding. If no destructor
(`dtor`) is given, will call :close on the resource.

boot.janet (435:1)

## with-dyns

macro

(with-dyns bindings & body)
Run a block of code in a new fiber that has some
dynamic bindings set. The fiber will not mask errors
or signals, but the dynamic bindings will be properly
unset, as dynamic bindings are fiber-local.

boot.janet (1668:1)

## with-env

macro

(with-env env & body)
Run a block of code with a given environment table

boot.janet (1679:1)

## with-syms

macro

(with-syms syms & body)
Evaluates `body` with each symbol in `syms` bound to a generated, unique symbol.

boot.janet (361:1)

## with-vars

macro

(with-vars vars & body)
Evaluates `body` with each var in `vars` temporarily bound. Similar signature to
`let`, but each binding must be a var.

boot.janet (1684:1)

## xprin

cfunction

(xprin to & xs)
Print to a file or other value explicitly (no dynamic bindings). The value to print to is the first argument, and is otherwise the same as `prin`. Returns nil.

../janet/src/core/io.c (597:1)

## xprinf

cfunction

(xprinf to fmt & xs)
Like `prinf` but prints to an explicit file or value `to`. Returns nil.

../janet/src/core/io.c (701:1)

## xprint

cfunction

(xprint to & xs)
Print to a file or other value explicitly (no dynamic bindings) with a trailing newline character. The value to print to is the first argument, and is otherwise the same as `print`. Returns nil.

../janet/src/core/io.c (588:1)

## xprintf

cfunction

(xprintf to fmt & xs)
Like `printf` but prints to an explicit file or value `to`. Returns nil.

../janet/src/core/io.c (694:1)

## yield

function

(yield &opt x)
Yield a value to a parent fiber. When a fiber yields, its execution is paused until another thread resumes it. The fiber will then resume, and the last yield call will return the value that was passed to resume.

## zero?

function

(zero? x)
Check if x is zero.

boot.janet (986:1)

## zipcoll

function

(zipcoll ks vs)
Creates a table from two arrays/tuples.
Returns a new table.

boot.janet (1790:1)