Builtin names

Every name a module has bound by default, by section. Each entry links to the page that documents it. A name can answer in more than one section – try is a layout handler and a special form, + a special form and an operator function – and Names with more than one meaning lists each of those with all its pages.

  • Layout handlers: block heads that read an indented block into a form

  • Special forms: forms the compiler handles directly

  • Macros: forms that expand to special forms

  • Fences: triple-backtick foreign literals

  • Runtime: types and type predicates, operators, functions, and exceptions

Layout handlers

Head

Peers

Reads to

any other head

(HEAD ARGS... BODY...), one argument per body line, keyword lines as keyword arguments

block-begin

(HEAD ARGS... (begin BODY...)); bind layout/<head> to it for a head that wants one body form

inline-block

(HEAD ARGS... ELEMENT...), every element of every body line spliced and nothing folded; bind layout/<head> to it for a head whose block only breaks a long line

if

elif, else

(cond [TEST BODY] ... [else: BODY])

while

else

(while TEST BODY... (else: BODY...))

for-each

else

(for-each [VAR SEQ] BODY... (else: BODY...))

try

except, else, finally

(try (begin BODY...) ([Type] BODY...) ... (else: ...) (finally: ...)), each except clause keeping the bracketed form as written

dyn-wind

before, after

(dyn-wind BEFORE (begin BODY...) AFTER), an absent peer emitting ()

switch

(switch SUBJECT [VALUE BODY...] ... [else: BODY...])

match

(match SUBJECT [[PATTERN...] BODY...] ... [else: BODY...])

class

(class NAME SUPERS (begin BODY...)), a class bound to NAME

build-class

(build-class NAME SUPERS (begin BODY...)), a class expression that binds nothing

global

the block of the word after global, read through that word’s layout, with global put back in front

syntax-rules

a syntax-rules transformer, one arm per rule block

syntax-match

a syntax-match transformer

macro-rules

a macro-rules transformer

macro-match

a macro-match transformer

special-rules

a special-rules transformer

special-match

a special-match transformer

bare-syntax

(bare-syntax [NAME] SLOT TEMPLATE), the arm for the name used as a lone atom

Special forms

Definition and binding

Form

Does

var

Bind a name in the current scope, with an optional type, or several names by unpacking

define

The Scheme-layer spelling of var, or of def when the name position is a pair [NAME FORMALS ...]

define-global

Bind a name at the module from any depth; what global var and global def lower to

define-values

Bind the names of a pattern in the current scope; what var over a pattern lowers to

define-global-values

Bind the names of a pattern at the module; what global var over a pattern lowers to

function

A named function value that is not bound

lambda

An anonymous function value; formals, defaults, rest collectors, annotations, by-ref

let

Lexical bindings for a body; named let for loops

letrec

Lexical bindings that may refer to each other

setq

Store into an existing binding; the special under set!

setq-values

Store into several bindings by unpacking

bindq

Bind a name to a ref

refq

The ref of a variable; the special under &name

deref

Read through a ref

takeq

Read a binding and clear it

delq

Delete a binding

globals, vars

The module namespace; the current scope’s namespace, or an object’s __dict__

parameter, parameterize

Read a dynamic parameter; rebind parameters for a body

Control flow

Form

Does

begin

Run forms in order; the value is the last

cond

The first clause whose test is true; what layout if reads to

switch

Branch on equality against candidates

match

Destructure against patterns; see Match patterns

and, or

Short-circuit conjunction and disjunction

while

Loop while a test is true, with an else: clause

for-each

Loop over an iterable, with destructuring and an else: clause

break, continue

Leave a loop, with an optional value; start the next iteration

return

Leave a function; several values return a tuple, keywords a values

try

Handle exceptions, with else: and finally: clauses

raise

Raise an exception, or re-raise the current one

check-exception, load-exception, clear-exception

Internal forms that try expands into

Objects, attributes, and items

Form

Does

attr, set-attr, del-attr

Read, store, delete an attribute; obj.name reads as attr

ref-attr, take-attr, inplace-attr

A ref to an attribute; take and delete; update in place

item, set-item, del-item

Read, store, delete a subscript; obj[key] reads as item

ref-item, take-item, inplace-item

A ref to a subscript; take and delete; update in place

inplace

Update a variable in place; the special under incr! and decr!

call

Call a value; forces a runtime call past a same-named macro

call-attr

Call a method by name; (obj.method ...) reads to this

build-class

Build a class value without binding a name; what class lowers to

instance?, subclass?

Type tests; a tuple as the second operand tests several types

#str, format

String conversion; format with an optional bare format spec

#list, #tuple, #list-append

Build a list or tuple; append to a list

Operators

Form

Does

==, !=, equal?, not-equal?

Equality, chained over any number of operands

<, <=, >, >=

Ordering, chained

le?, ge?

Aliases for <= and >=

**

Exponentiation with an optional modulus

in, not-in, is, is-not

Membership and identity, each with a ?-suffixed alias

not, truth, nil?, repr, len, type, dir, vars, iter, next, divmod

The unary and inspection operators

Object operators

The arithmetic, bitwise, and unary operators, constant folding, and the comparison table

Pairs and quoting

Form

Does

cons, car, cdr

Build a pair chain; its first element; its rest

bracket-cons, bracket-proper

Build a bracket pair chain; a proper bracket list

quote

A form as data; 'form

quote-syntax

A form as data, keeping hygiene marks; #'form; what a transformer’s patterns and templates are quoted with

quasiquote, unquote, unquote-splicing

A template; `form, ,form, ,@form

quasiquote-syntax

A template keeping hygiene marks; #`form; what a procedural macro a template defines builds its output with

Block quote, block quasiquote

The reader shorthands 'head: and `head:, which quote an indented block as its #block: cons; #'head: and #`head: do the same keeping hygiene marks

Async, generators, and continuations

Form

Does

await

Await a held awaitable; bare (await) is a cooperative suspend

yield, yield-from

Generator and coroutine suspension; delegation

with, dyn-with

Context managers, lexical and dynamic-extent

dyn-wind

Before and after thunks around a body, rerun across continuation jumps

reset, shift

Delimited continuations

call/cc, let/cc, capture/cc

Undelimited continuations, from the Scheme form down to the raw capture

Modules

Form

Does

import

Import a module; [MODULE as: NAME] binds the leaf

import-from

Import names from a module, with aliases

import-all-from

Bind a module’s public names, at module level only

use

Import a feature with all its facets, a macro together with its runtime sibling

Macro definition and the compiler

Form

Does

syntax-rules, syntax-match

Template transformers, by rule list and by named spec

macro-rules, macro-match

Procedural transformers

special-rules, special-match

Transformers that receive the compiler and emit bytecode

bare-syntax

The arm used when a syntax name appears as a lone atom

gensym-thunk

The {...} thunk with inferred %1, %2 formals

apply-fence

Expand a fenced foreign literal through its handler

bytecode

Inject bytecode directly

Operator names

Form

Does

+, -, *, /, //, %, **, @, &, |, ^, ~, <<, >>, divmod

Arithmetic and bitwise operators

==, !=, <, <=, >, >=, equal?, not-equal?, lt?, le?, gt?, ge?

Comparison operators and their aliases

in, not-in, is, is-not, in?, not-in?, is?, is-not?

Membership and identity operators and their aliases

Macros

Binding and assignment

Macro

Does

set!

Store into a name, attribute, subscript, or ref, choosing the special by target shape

incr!, decr!

Add to or subtract from a binding in place

del!

Delete a name, attribute, or subscript

take!

Read a name, attribute, or subscript and clear it

bind!

Bind a name to a ref, typed by the target shape

ref

A ref to a name, attribute, subscript, or parameter

unassigned?, default!

Whether a location holds a value; store one unless it already does

let*

Sequential let, each binding seeing the ones before

let-values

let with unpacking

labels, flet

Local functions for a body, mutually recursive and not

define-parameter

Declare a dynamic parameter

define-environ

Bind a name to an environment variable

declare-exports

Name the module’s public features

entry-point

Mark the function a program runs once its module has loaded

Conditionals

Macro

Does

if

Two-armed conditional over cond

when, unless

One-armed conditionals

?

Conditional with a boolean default

bool

Truthiness as a boolean

None?

Identity test against the None singleton

has?

Membership

assert

Raise AssertionError unless a test holds; removable by pragma

pass

A no-op expression, and a bare control word

Definitions

Macro

Does

def

Define a function and bind it in the current scope

global

Prefix over var, def, class and syntax that binds the form at the module

class

Define a class and bind it in the current scope

super

The superclass proxy inside a method

decorate, decorate-subject

What @ lines lower to, and the per-decorator dispatch

when-main

Python’s __name__ guard; prefer entry-point for a program’s work

Iteration and collections

Macro

Does

each

A generator over a [var seq] binding, with when: and unless: filters

list-each

A list from the same shape

dict-each

A dict from key: and value: clauses

slice, item-slice

A slice object; a slice of a sequence

item*, attr*

Nested item and attribute chains

cadr … caddddr, first … fifth

Positions in a pair chain

function-compose

Compose functions right to left

Macros about macros

Macro

Does

syntax

A transformer bound at the module from top level, or for the rest of a body inside one

define-syntax

The Scheme-layer spelling: a transformer bound at the module, with any of the rule and match kinds or a bare form; its template names are kept apart from the use site, see Hygiene

extend-syntax

Add arms to an existing transformer

let-syntax

A transformer scoped to a body

inline-macro

Run a body at expand time and splice its result

datum

Capture a form with its source position for hygiene

datumq

The same without evaluating the argument; in a template, writes a form raw (-'form)

define-fence

Define a fence handler for a triple-backtick literal

macroexpand, macroexpand-1

Expand a form fully, or by one step

macroexpandq, macroexpandq-1

The same without quoting the form

compileq, evaluate, get-compiler

Compile, evaluate, and reach the compiler from a program

pragma

Set or read a module’s reader and compiler settings

help

Documentation for a name

Fences

Name

Does

fence/bash

A bash script as a literal, run through run-process

Runtime

Types and type predicates

Each type is bound with its NAME? predicate: int and int?, list and list?, and so on.

Name

Does

bool, int, float, complex, decimal, fraction

Numbers

str, bytes, bytearray, memoryview

Text and bytes

list, tuple, dict, set, frozenset, range, slice

Collections

object, type, property, classmethod, staticmethod

Objects and classes

pair, symbol, keyword, datum

Pairs and symbols

partial, demand, constantly, values, defer

Functions and results

map, filter, zip, py-map, py-filter, py-zip

Iterators

Ref, ItemRef, AttributeRef, DynamicRef, ConstantRef, MemoizedRef, ParamRef, ref?

Refs

ProcessResult

The result of run-process

Operators

Name

Does

+, -, *, /, //, **, @, &, |, ^, <<, >>

Arithmetic and bitwise

==, !=, <, <=, >, >=, equal?, not-equal?, lt?, le?, gt?, ge?

Comparison, chained

in, not-in, in?, not-in?, is?, is-not?

Membership and identity

Functions

Name

Does

instance?, subclass?, callable?, None?, nil?, proper?, recursive?, all?, any?, hasattr?, on-demand?

Predicates

cons, build-proper, car, cdr, cadr, caddr, cadddr, caddddr, cddr, cdddr, cddddr, first, second, third, fourth, fifth, set-car, set-cdr, unpack, bracket-cons, bracket-splice

Pairs

#list, #tuple, #set, #dict, #str, #list-append

Collection builders

apply, identity, constantly, partial, demand, demand-call, demand-apply, values, decorate-wraps

Calling

defer, create-task, coroutine-fn, run-process

Async

iter, next, sorted, max, min, len, sum, enumerate, reversed, map, filter, zip

Iteration

repr, py-repr, format, abs, round, bin, hex, oct, chr, ord, ascii, hash, id

Conversion and display

print, input, open

Input and output

getattr, setattr, vars, dir, itemgetter, attrgetter, super, getattr*, hasattr*, getitem*, hasitem*, build-slice, koskari-vars

Attributes and items

deref, parameter, environ-ref

Refs, parameters, and the environment

compile, evaluate, get-compiler, macroexpand, macroexpand-1, apply-layout, apply-layouts, help, gensym, active-pragma, help-pragma-key, build-syntax, build-macro, build-special, build-bare-syntax

Compilation and expansion

None, True, False, Ellipsis, ..., NotImplemented, nil, bracket-nil

Constants

Exceptions

Name

Does

KoskariException, NotYetImplemented, KoskariSyntaxError, ReaderError, ReaderSyntaxError, ReaderEOF, FormatStringSyntaxError, LayoutError, CompilerError, SpecialError, SyntaxMatchError, FenceError, ParametersError, UncaughtCompilerError, KoskariContinuationError, KoskariPromptNotFound, KoskariPromptUnreachable, KoskariSyncViolation

The Koskari exceptions; every Python exception type is bound as well

Names with more than one meaning

Name

Meanings

bare-syntax

layout handler, special form

bool

macro, type

bracket-cons

function, special form

build-class

layout handler, special form

caddddr

function, macro

cadr

function, macro

car

function, special form

cdr

function, special form

class

layout handler, macro

cons

function, special form

constantly

function, type

datum

macro, type

defer

function, type

demand

function, type

deref

function, special form

dir

function, special form

dyn-wind

layout handler, special form

equal?

operator function, special form

evaluate

function, macro

fifth

function, macro

filter

function, type

first

function, macro

for-each

layout handler, special form

format

function, special form

ge?

operator function, special form

get-compiler

function, macro

global

layout handler, macro

gt?

operator function, special form

help

function, macro

if

layout handler, macro

in?

operator function, special form

in

operator function, special form

instance?

function, special form

is-not?

operator function, special form

is?

operator function, special form

iter

function, special form

len

function, special form

le?

operator function, special form

#list-append

function, special form

#list

function, special form

lt?

operator function, special form

macroexpand-1

function, macro

macroexpand

function, macro

macro-match

layout handler, special form

macro-rules

layout handler, special form

map

function, type

match

layout handler, special form

next

function, special form

nil?

function, special form

None?

function, macro

not-equal?

operator function, special form

not-in?

operator function, special form

not-in

operator function, special form

**

operator function, special form

&

operator function, special form

*

operator function, special form

+

operator function, special form

-

operator function, special form

//

operator function, special form

/

operator function, special form

<<

operator function, special form

>>

operator function, special form

@

operator function, special form

|

operator function, special form

^

operator function, special form

==

operator function, special form

!=

operator function, special form

>=

operator function, special form

>

operator function, special form

<=

operator function, special form

<

operator function, special form

parameter

function, special form

partial

function, type

repr

function, special form

slice

macro, type

special-match

layout handler, special form

special-rules

layout handler, special form

#str

function, special form

subclass?

function, special form

super

function, macro

switch

layout handler, special form

syntax-match

layout handler, special form

syntax-rules

layout handler, special form

try

layout handler, special form

#tuple

function, special form

type

special form, type

values

function, type

vars

function, special form

while

layout handler, special form

zip

function, type