blob: 78c62559b30e428cfd236ed0c26f2024f90ef452 [file] [log] [blame]
swissChili8a4b4ed2021-08-03 19:27:32 -07001\documentclass[letterpaper,11pt,twocolumn]{article}
2\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}\usepackage[T1]{fontenc}
3\usepackage[utf8]{inputenc}
4\usepackage{lmodern}
5\usepackage{amsmath}
6\usepackage{amsfonts}
7\usepackage{amssymb}
8\usepackage{amsthm}
9\usepackage{graphicx}
10\usepackage{color}
11\usepackage{xcolor}
12\usepackage{url}
13\usepackage{textcomp}
14\usepackage{listings}
15\usepackage{glossaries}
16\usepackage{parskip}
17\usepackage{imakeidx}
18\usepackage[normalem]{ulem}
19
20\title{Bluejay Lisp Reference}
21\author{swissChili}
22\date{Development Version: \today}
23
24\newcommand{\startexplanation}{$\triangleright$\hskip1.4ex}
swissChili3e57d7c2022-08-01 21:40:25 -070025\newenvironment{defin}[1]
26 {#1
27 \begin{quote}\startexplanation}
28 {\end{quote}}
29
swissChili8a4b4ed2021-08-03 19:27:32 -070030\newcommand{\plus}{\texttt{+}}
31\newcommand{\pluses}[1]{\plus{}#1\plus{}}
32\newcommand{\earmuff}{\texttt{*}}
33\newcommand{\earmuffs}[1]{\earmuff{}#1\earmuff{}}
34\newcommand{\func}[1]{\text{$_f$\textbf{#1}}}
35\newcommand{\mac}[1]{\text{$_m$\textbf{#1}}}
36\newcommand{\reader}[1]{\text{$_r$\textbf{#1}}}
37\newcommand{\const}[1]{\text{$_c$\textbf{#1}}}
38\newcommand{\var}[1]{\text{$_v$\textbf{#1}}}
39\newcommand{\param}[1]{\textit{#1}}
40\newcommand{\ret}[1]{\uline{#1}}
41\newcommand{\type}[1]{\text{$_t$\textbf{#1}}}
42\newcommand{\more}{ \ldots}
43\newcommand{\T}{\texttt{t}}
44\newcommand{\nil}{\texttt{nil}}
45\newcommand{\default}[1]{\text{\textsubscript{
swissChili36f2c692021-08-08 14:31:44 -070046 \setlength{\fboxsep}{1pt}\setlength{\fboxrule}{0.2bp}%
47 \fbox{#1}}}}
swissChili8a4b4ed2021-08-03 19:27:32 -070048\newcommand{\opt}[2]{\text{$[$}\param{#1}\default{#2}\text{$]$}}
49\newcommand{\mut}[1]{\text{$\widetilde{#1}$}}
swissChilia89ee442021-08-04 20:54:51 -070050\newcommand{\mighteval}[1]{\text{$\widehat{#1}$}}
swissChili8a4b4ed2021-08-03 19:27:32 -070051\newcommand{\super}[1]{\text{$ ^{#1} $}}
52
53\newcommand{\optlist}[1]{\text{\(
54 \left\{
swissChili36f2c692021-08-08 14:31:44 -070055 \begin{array}{l}
swissChili8a4b4ed2021-08-03 19:27:32 -070056 #1
swissChili36f2c692021-08-08 14:31:44 -070057 \end{array}
swissChili8a4b4ed2021-08-03 19:27:32 -070058 \right\}
swissChili36f2c692021-08-08 14:31:44 -070059 \)}}
swissChili8a4b4ed2021-08-03 19:27:32 -070060
61\makeindex
62\makeglossaries
63
swissChili36f2c692021-08-08 14:31:44 -070064\newglossaryentry{closure}{name={closure},description={A
65 \type{function-object} that captures certain variables from its
66 defining context}}
swissChili8a4b4ed2021-08-03 19:27:32 -070067
swissChili36f2c692021-08-08 14:31:44 -070068\newglossaryentry{lexical-scope}{name={lexical scope},description={A
69 method of scoping where the values in scope at a given time are
70 determined by the static content of the source program, not by the
71 state of the callstack or other execution details. This allows for
72 example closures to \gls{closure}s to capture some of the state of
73 their defining context}}
swissChili8a4b4ed2021-08-03 19:27:32 -070074
swissChili36f2c692021-08-08 14:31:44 -070075\newglossaryentry{truthy}{name={truthy},description={A value that is
76 not \nil}}
swissChili8a4b4ed2021-08-03 19:27:32 -070077
78\begin{document}
79
80\maketitle
81\tableofcontents
82
83\section{Introduction}
84
swissChili36f2c692021-08-08 14:31:44 -070085This document provides a brief reference to the Bluejay Lisp language
swissChili3e57d7c2022-08-01 21:40:25 -070086and standard library. It documents every currently included function,
87macro, reader macro, and special form.
88
89\subsection{Running Bluejay Lisp}
90
91Assuming you have compiled Bluejay Lisp, you should have a
92\texttt{lisp} executable in your \texttt{src/lisp} directory. Invoking
93\texttt{lisp} without arguments will drop you into an interactive
94read-evaluate-print loop, or REPL.\@ Here you can type Lisp code one
95line at a time---the result will be immediately displayed. If you wish
96to run a specific Lisp file, you may pass its path as the first
97argument to \texttt{lisp}, e.g. \texttt{lisp hello-world.lisp}.
98
99Note that in order to load the standard library, the compiler must
100know where Bluejay Lisp libraries are stored. When loading a library,
101the compiler checks the \texttt{LISP\_LIBRARY\_PATH} environment
102variable. If it is blank, it assumes the library path is
103\texttt{/lib/lisp}. To use the standard library included with Bluejay,
104set the environment variable to the path of the included
105\texttt{lib/lisp} directory.
swissChili8a4b4ed2021-08-03 19:27:32 -0700106
107\subsection{Typography}
108
swissChili36f2c692021-08-08 14:31:44 -0700109The following text styles and symbols are used within this document to
swissChili3e57d7c2022-08-01 21:40:25 -0700110indicate particular types, values, or meanings:
swissChili8a4b4ed2021-08-03 19:27:32 -0700111
swissChilia89ee442021-08-04 20:54:51 -0700112\begin{tabular}[t]{p{0.2\linewidth} p{0.64\linewidth}}
swissChili3e57d7c2022-08-01 21:40:25 -0700113 \func{cons} & A function \param{cons}. \\
114 \const{\plus{}foo\plus} & A constant \param{\plus{}foo\plus}. \\
115 \var{\earmuff{}bar\earmuff} & A global variable \param{\earmuff{}bar\earmuff}. \\
116 \reader{baz} & A reader macro \param{baz}. \\
117 \mac{quux} & A macro \param{quux}. \\
118 \param{parameter} & A function argument \param{parameter} \\
119 \opt{var}{123} & An optional function argument \param{var} with the default value \param{123}. \\
120 \param{args}\more & \param{args} represents the rest of the items in the list. \\
121 \mut{\param{mut}} & A function argument \param{mut} that might be mutated. \\
122 \mighteval{\param{maybe}} & \param{maybe} may or may not be evaluated. \\
123 \ret{value} & Indicates that a form will evaluate to \param{value}. \\
124 \type{integer} & The type \param{integer}. \\
125 \optlist{\text{a}\\\text{b}} & One of \param{a} or \param{b}.
swissChili8a4b4ed2021-08-03 19:27:32 -0700126\end{tabular}
127
128\section{Primitives}
129
130\subsection{Type Predicates}
131
swissChili3e57d7c2022-08-01 21:40:25 -0700132\begin{defin}{
133 (\optlist{
134 \func{nilp} \text{ or } \func{not} \\
135 \func{closurep} \text{ or } \func{functionp} \\
136 \func{integerp} \\
137 \func{consp} \\
138 \func{symbolp}
139 } \param{value})\index{nilp}\index{not}
140 }
swissChili36f2c692021-08-08 14:31:44 -0700141 \ret{\T} if \param{value} is of the specified type, \ret{\nil}
142 otherwise.
swissChili3e57d7c2022-08-01 21:40:25 -0700143\end{defin}
144
145\begin{defin}{(\func{listp} \param{value})}
146 \ret{\T} if \param{value} is a well-formed \type{cons} list,
147 i.e.\ if (\func{consp} \param{value}) and the (\func{cdr}
148 \param{value}) is a well-formed \type{cons} list or \nil.
149\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700150
151\subsection{Definitions and Variables}
152
swissChili3e57d7c2022-08-01 21:40:25 -0700153\begin{defin}{
154 (\mac{defun} \param{name} (\param{args}\more) \param{body}\more)\index{defun} \\
155 (\mac{defmacro} \param{name} (\param{args}\more) \param{body}\more)\index{defmacro}
156 }
swissChili36f2c692021-08-08 14:31:44 -0700157 Define a function or macro respectively, taking \param{args}
158 arguments and evaluating \param{body} in turn, finally evaluating to
159 \ret{the final entry in \param{body}} or \ret{\nil} if \param{body}
160 is empty.
swissChili3e57d7c2022-08-01 21:40:25 -0700161\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700162
swissChili3e57d7c2022-08-01 21:40:25 -0700163\begin{defin}{
164 (\mac{let1} (\param{variable} \param{form}) \param{body}\more)\index{let1} \\
165 (\mac{let} ((\param{variable} \param{form})\more) \param{body}\more)\index{let}
166 }
swissChili36f2c692021-08-08 14:31:44 -0700167 First evaluate \param{form}, binding it to \param{variable}. Then
168 evaluate \param{body}, finally evaluating to \ret{the final entry in
169 \param{body}} or \ret{\nil} if \param{body} is
170 empty. \param{variable} is no longer in scope after this form ends.
swissChilifc5c9412021-08-08 19:08:26 -0700171 \mac{let} is similar to \mac{let*} in other lisps, later variables
172 can reference previous ones.
swissChili3e57d7c2022-08-01 21:40:25 -0700173\end{defin}
swissChilifc5c9412021-08-08 19:08:26 -0700174
swissChili3e57d7c2022-08-01 21:40:25 -0700175\begin{defin}{
176 (\mac{flet1} (\param{name} (\param{args}\more) \param{body}\more)) \\
177 (\mac{flet} ((\param{name} (\param{args}\more)\more) \param{body}\more))
178 \index{flet}\index{flet1}
179 }
swissChilifc5c9412021-08-08 19:08:26 -0700180 Like \mac{let} and \mac{let1} but creates a lambda. Unlike other
181 lisps the defined function remains in the variable namespace as a
182 \type{function-object}.
swissChili3e57d7c2022-08-01 21:40:25 -0700183\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700184
swissChili3e57d7c2022-08-01 21:40:25 -0700185\begin{defin}{
186 \reader{\textquotesingle}\param{value} \\ (\mac{quote}
187 \param{value})\index{quote} } \ret{Return \param{value}} as an
188 expression, without evaluating it.
189\end{defin}
swissChili36f2c692021-08-08 14:31:44 -0700190
swissChili3e57d7c2022-08-01 21:40:25 -0700191\begin{defin}{
192 \reader{\`}\param{value} \\
193 (\mac{backquote} \param{value})\index{backquote}\index{\`}
194 }
195 Return \ret{\param{value}} unevaluated, except for any \mac{unquote}
swissChili36f2c692021-08-08 14:31:44 -0700196 and \mac{unquote-splice} forms (and their reader-macro equivalents).
swissChili3e57d7c2022-08-01 21:40:25 -0700197\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700198
swissChili3e57d7c2022-08-01 21:40:25 -0700199\begin{defin}{
200 \reader{,}\param{value} \\
201 (\mac{unquote} \param{value}) \\
202 \reader{,\texttt{@}}\param{value} \\
203 (\mac{unquote-splice} \param{value})
204 \index{unquote}\index{unquote-splice}
205 \index{,}\index{,@}
206 }
swissChili3f7f5842021-08-08 17:13:45 -0700207 In the context of a \mac{backquote}, evaluate \param{value} instead of
208 using it as-is. \mac{unquote-splice} and \reader{,\texttt{@}} take a
209 list as their argument, and ``splice'' each element in to
210 the \mac{backquote} list so that each element of that argument corresponds
211 to an element of the \mac{backquote} list.
212 The other two macros insert their argument as a single element in the list.
swissChili3e57d7c2022-08-01 21:40:25 -0700213\end{defin}
swissChili3f7f5842021-08-08 17:13:45 -0700214
swissChili8a4b4ed2021-08-03 19:27:32 -0700215\subsection{Control Flow}
216
swissChili3e57d7c2022-08-01 21:40:25 -0700217\begin{defin}{
218 (\mac{if} \param{predicate} \param{then} \opt{otherwise}{nil})\index{if} \\
219 (\mac{when} \param{predicate} \param{then\more})\index{when} \\
220 (\mac{unless} \param{predicate} \param{otherwise\more})\index{unless}
221 }
swissChili36f2c692021-08-08 14:31:44 -0700222 First evaluate \param{predicate}. If it is \gls{truthy} evaluate and
223 return \ret{\param{then}}, otherwise \ret{\param{otherwise}}. If
224 either is not provided return \ret{\nil}.
swissChili3e57d7c2022-08-01 21:40:25 -0700225\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700226
swissChili3e57d7c2022-08-01 21:40:25 -0700227\begin{defin}{
228 (\mac{progn} \opt{forms\more}{nil})\index{progn}
229 }
swissChili36f2c692021-08-08 14:31:44 -0700230 Evaluate \param{forms} from first to last, finally returning
231 \ret{the last form}.
swissChili3e57d7c2022-08-01 21:40:25 -0700232\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700233
swissChili3e57d7c2022-08-01 21:40:25 -0700234\begin{defin}{
235 (\mac{and} \param{first} \param{\mighteval{rest}}\more)\index{and} \\
236 (\mac{or} \param{first} \param{\mighteval{rest}}\more)\index{or}
237 }
swissChili36f2c692021-08-08 14:31:44 -0700238 Short circuiting $\land$ and $\lor$, respectively. Return the first
239 value that is \nil{} or truthy, respectively, or the last value if
240 all are truthy/\nil{}.
swissChili3e57d7c2022-08-01 21:40:25 -0700241\end{defin}
swissChilia89ee442021-08-04 20:54:51 -0700242
swissChili8a4b4ed2021-08-03 19:27:32 -0700243\section{Numbers}
244
245\subsection{Integers}
246
swissChili3e57d7c2022-08-01 21:40:25 -0700247\begin{defin}{
248 (\optlist{
249 \func{$+$} \\
250 \func{$-$} \\
251 \func{$*$} \\
252 \func{$/$}
253 } \param{a b})
254 }
swissChili36f2c692021-08-08 14:31:44 -0700255 The \ret{sum, difference, product, or quotient} of \param{a} and
256 \param{b} as an \type{integer}.
swissChili3e57d7c2022-08-01 21:40:25 -0700257\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700258
swissChili3e57d7c2022-08-01 21:40:25 -0700259\begin{defin}{
260 (\func{=} \param{a b})
261 }
swissChili36f2c692021-08-08 14:31:44 -0700262 \ret{\T} if \param{a} and \param{b} hold the same \type{integer}
263 value, \ret{\nil} otherwise.
swissChili3e57d7c2022-08-01 21:40:25 -0700264\end{defin}
265
266\begin{defin}{(\optlist{\func{$<$} \\ \func{$>$}} \param{a} \param{b})}
267 \ret{\T} if \param{a} is less than or greater than \param{b},
268 respectively; \ret{\nil} otherwise.
269\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700270
271\section{Function Manipulation}
272
swissChili3e57d7c2022-08-01 21:40:25 -0700273\begin{defin}{
274 (\func{funcall} \param{args}\more)\index{funcall} \\
275 (\func{apply} \param{function} \param{args})\index{apply}
276 }
swissChili36f2c692021-08-08 14:31:44 -0700277 Call the \type{closure} or \type{function-object} \param{function}
278 with \param{args} and evaluate to \ret{its result}. An error occurs
279 if \param{args} are not acceptable.
swissChili3e57d7c2022-08-01 21:40:25 -0700280\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700281
swissChili3e57d7c2022-08-01 21:40:25 -0700282\begin{defin}{
283 (\func{recurse} \param{args}\more)\index{recurse} } In a lambda
284 definition, call the current lambda with
285 \param{args}. \func{recurse} can also be used as an argument to
286 \func{function} and \reader{\#\textquotesingle} to refer to the
287 current lambda.
288\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700289
swissChili3e57d7c2022-08-01 21:40:25 -0700290\begin{defin}{
291 (\mac{function} \param{function-name})\index{function} \\
292 \reader{\#\textquotesingle}\param{function-name}\index{\#\textquotesingle}
293 }
swissChili36f2c692021-08-08 14:31:44 -0700294 Create a \ret{\type{function-object} from an existing function or
295 macro}. \param{function} must be a symbol literal at compile time.
swissChili3e57d7c2022-08-01 21:40:25 -0700296\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700297
swissChili3e57d7c2022-08-01 21:40:25 -0700298\begin{defin}{
299 (\func{lambda} (\param{args}\more) \param{body}\more)\index{lambda}
300 }
swissChili36f2c692021-08-08 14:31:44 -0700301 Create a \ret{lexically-scoped \type{\gls{closure}}} taking
302 \param{args} and evaluating to \param{body}.
swissChili3e57d7c2022-08-01 21:40:25 -0700303\end{defin}
swissChili36f2c692021-08-08 14:31:44 -0700304
swissChili3e57d7c2022-08-01 21:40:25 -0700305\begin{defin}{
306 (\func{eval} \param{form})\index{eval}
307 }
swissChili36f2c692021-08-08 14:31:44 -0700308 Evaluate and return \ret{\param{form}} in the current global
309 environment. The evaluated form does not use \gls{lexical-scope}.
swissChili3e57d7c2022-08-01 21:40:25 -0700310\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700311
312\section{Lists}
313
314\subsection{Creating Lists}
315
swissChili3e57d7c2022-08-01 21:40:25 -0700316\begin{defin}{
317 (\func{cons} \param{a} \param{b})\index{cons}
318 }
swissChili36f2c692021-08-08 14:31:44 -0700319 Join \param{a} and \param{b} into a \ret{\type{cons} pair}.
swissChili3e57d7c2022-08-01 21:40:25 -0700320\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700321
swissChili3e57d7c2022-08-01 21:40:25 -0700322\begin{defin}{
323 (\func{list} \param{values}\more)\index{list}
324 }
swissChili36f2c692021-08-08 14:31:44 -0700325 Construct a \ret{\type{cons}-list of \param{values}}.
swissChili3e57d7c2022-08-01 21:40:25 -0700326\end{defin}
327
328\begin{defin}{(\func{append} \param{first} \param{rest})}
329 If \param{first} is a list, return \ret{a list with all the elements
330 of \param{first} followed by the elements of
331 \param{rest}}. Otherwise, return \ret{(\func{cons} first rest)}.
332\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700333
334\subsection{Deconstructing Lists}
335
swissChili3e57d7c2022-08-01 21:40:25 -0700336\begin{defin}{
337 (\func{length} \param{list})\index{list}
338 }
swissChili36f2c692021-08-08 14:31:44 -0700339 Return the \ret{length of \param{list}} if it is a \type{cons}-list,
340 \nil{} otherwise.
swissChili3e57d7c2022-08-01 21:40:25 -0700341\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700342
swissChili3e57d7c2022-08-01 21:40:25 -0700343\begin{defin}{
344 (\func{car} \param{pair})\index{car} \\
345 (\func{cdr} \param{pair})\index{cdr}
346 }
swissChili36f2c692021-08-08 14:31:44 -0700347 Return the \ret{first or second item} of \type{cons} \param{pair},
348 respectively.
swissChili3e57d7c2022-08-01 21:40:25 -0700349\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700350
swissChili3e57d7c2022-08-01 21:40:25 -0700351\begin{defin}{
352 (\optlist{
353 \func{caar}\\
354 \func{cadr}\\
355 \func{caddr}\\
356 \func{cadar}\\
357 \func{caddar}
358 } \param{val})
359 }
swissChili36f2c692021-08-08 14:31:44 -0700360 Behave like a combination of \func{car} and \func{cdr} would.
swissChili3e57d7c2022-08-01 21:40:25 -0700361\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700362
swissChili3e57d7c2022-08-01 21:40:25 -0700363\begin{defin}{
364 (\func{elt} \param{list} \param{n})\index{elt}
365 }
swissChili36f2c692021-08-08 14:31:44 -0700366 Return the \ret{\param{n}\super{th} element of \param{list}},
367 starting from 0, or \ret{\nil} if \param{n} $ \ge $ (\func{length}
368 \param{list}) or \param{list} is not a \type{cons}-list or \param{n}
369 is not an \type{integer}.
swissChili3e57d7c2022-08-01 21:40:25 -0700370\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700371
372\subsection{Operating on Lists}
373
swissChili3e57d7c2022-08-01 21:40:25 -0700374\begin{defin}{
375 (\func{mapcar} \param{fun} \param{list})\index{mapcar}
376 }
swissChili36f2c692021-08-08 14:31:44 -0700377 Apply \param{fun} to each element of \param{list}, returning a
378 \ret{new \type{cons}-list} containing the results of the respective
379 applications of \param{fun}.
swissChili3e57d7c2022-08-01 21:40:25 -0700380\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700381
swissChili3e57d7c2022-08-01 21:40:25 -0700382\begin{defin}{
383 (\optlist{\func{remove-if}\\\func{remove-if-not}}
384 \param{predicate} \param{list})\index{remove-if}\index{remove-if-not}
385 }
swissChili36f2c692021-08-08 14:31:44 -0700386 Return a \ret{new \type{cons}-list} of all the items of \param{list}
387 that either do not or do satisfy \param{predicate}, respectively.
swissChili3e57d7c2022-08-01 21:40:25 -0700388\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700389
swissChili3e57d7c2022-08-01 21:40:25 -0700390\begin{defin}{
391 (\func{reduce} \param{fun} \param{list} \opt{initial-value}{\nil})
392 }
swissChili36f2c692021-08-08 14:31:44 -0700393 Apply \param{fun} to two arguments at a time, starting with
394 \param{initial-value} and (\func{car} \param{list}) and continuing
395 with the result of the previous invocation and the successive
396 element of \param{list}. Return \ret{the result of the final
397 invocation}, or \ret{\param{initial-value}} if \param{list} is
398 empty.
swissChili3e57d7c2022-08-01 21:40:25 -0700399\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700400
401\section{Input \& Output}
402
swissChili3e57d7c2022-08-01 21:40:25 -0700403\begin{defin}{
404 (\func{print} \param{value})\index{print}
405 }
swissChili36f2c692021-08-08 14:31:44 -0700406 Print \param{value} to standard output. Return \ret{\nil}.
swissChili3e57d7c2022-08-01 21:40:25 -0700407\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700408
swissChili3e57d7c2022-08-01 21:40:25 -0700409\begin{defin}{
410 (\func{read})\index{read}
411 }
swissChili36f2c692021-08-08 14:31:44 -0700412 Read and return an \ret{S-expression} from standard input
swissChili3e57d7c2022-08-01 21:40:25 -0700413\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700414
415\subsection{Loading Programs}
416
swissChili3e57d7c2022-08-01 21:40:25 -0700417\begin{defin}{
418 \const{\pluses{current-file}}\index{\pluses{current-file}} }
419 \ret{A string} containing the path of the file currently being
420 compiled, or \ret{\nil{}} if not compiling a file (e.g.\ when
421 compiling a string).
422\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700423
swissChili3e57d7c2022-08-01 21:40:25 -0700424\begin{defin}{
425 (\func{load} \param{lisp-file})\index{load}
426 }
swissChili36f2c692021-08-08 14:31:44 -0700427 Load and evaluate \type{string} \param{lisp-file} as a local path
428 relative to the current file, or the current working directory if
429 not compiling a file. Return \ret{\nil}.
swissChili3e57d7c2022-08-01 21:40:25 -0700430\end{defin}
swissChili8a4b4ed2021-08-03 19:27:32 -0700431
swissChili04d94162022-07-30 21:46:49 -0700432\section{Inspecting \& Modifying the Environment}
433
434\subsection{Managing Memory}
435
swissChili3e57d7c2022-08-01 21:40:25 -0700436\begin{defin}{
437 (\func{gc})\index{gc}
438 }
swissChili04d94162022-07-30 21:46:49 -0700439 Run the garbage collector.
swissChili3e57d7c2022-08-01 21:40:25 -0700440\end{defin}
swissChili04d94162022-07-30 21:46:49 -0700441
swissChili3e57d7c2022-08-01 21:40:25 -0700442\begin{defin}{
443 (\func{gc-stats})\index{gc-stats}
444 }
swissChili04d94162022-07-30 21:46:49 -0700445 Return some
446 statistics about the garbage collector, in the form of a list:
447 \ret{(\param{total-allocs} \param{gc-runs})}, where
448 \param{total-allocs} is the current number of active allocations,
449 and \param{gc-runs} is the total number of times the garbage
450 collector has been run.
swissChili3e57d7c2022-08-01 21:40:25 -0700451\end{defin}
swissChili04d94162022-07-30 21:46:49 -0700452
453\subsection{Introspection}
454
swissChili3e57d7c2022-08-01 21:40:25 -0700455\begin{defin}{ \const{\pluses{current-env}} }
456 An opaque object representing the current environment.
457\end{defin}
swissChili04d94162022-07-30 21:46:49 -0700458
swissChili3e57d7c2022-08-01 21:40:25 -0700459\begin{defin}{ (\func{env-functions} \param{current-env}) }
460 Returns a list of symbols, each of which is the name of a function
461 defined in the environment specified by \param{current-env}.
462\end{defin}
swissChili04d94162022-07-30 21:46:49 -0700463
swissChili8a4b4ed2021-08-03 19:27:32 -0700464\printindex
465
466\printglossaries
467
468\end{document}