首页 / Documentation

文档

解释器目前接受什么的参考。凡是尚未实现的部分,参考中如实说明,而不是略去不提。

阅读文档 源代码

本节尚未翻译成你的语言,暂时以英文显示。欢迎提交翻译。

值

TypeMeansWritten as
nilThe absence of a value, and the result of a branch with no alternative.nil
booleanTrue or false. Only false is falsey.#t #f
integerA signed 64-bit integer.42 -7
floatA double-precision number.3.14
runeA Unicode code point.\u00e9
stringAn immutable sequence of bytes, written as text."hello"
symbolAn interned name. Evaluating one looks it up.foo bar?
keywordAn interned name that evaluates to itself.:a
pairA cons cell: a value and the rest of the list.(1 2 3) '()
vectorAn immutable indexed sequence.[1 2 3]
tableAn immutable string-keyed map with sorted keys, so output is stable.{:a 1}
arrayA mutable indexed sequence.@[1 2 3]
closureA procedure and the environment it captured.(lambda (x) ...)
primitiveA built-in procedure implemented in V.+ car

本节尚未翻译成你的语言,暂时以英文显示。欢迎提交翻译。

核心形式

FormMeaningDesugars to
ifEvaluate the test, then one branch. With no alternative the result is nil.`if`
defineBind a name in the current frame. A list target defines a procedure.`define`
set!Assign to the frame that owns the binding, so a closure sees the change on its next call.`set!`
lambdaCreate a procedure. fn is a synonym.`lambda`, `fn`
beginEvaluate in order, return the last. The last form keeps its tail position, so tail calls inside a begin are still tail calls.`begin`
letBind names and evaluate the body in a new frame. let binds simultaneously, let* in order, letrec with every name visible to every value.`let`, `let*`, `letrec`
andShort-circuit. Return the first falsey value, or the last value.`and`, `or`
quoteReturn the form itself instead of evaluating it. The apostrophe is shorthand.`quote`

本节尚未翻译成你的语言,暂时以英文显示。欢迎提交翻译。

派生形式

FormMeaningDesugars to
whenRun the body only if the test is true, otherwise nil.`if`
unlessRun the body only if the test is false, otherwise nil.`if`
condTry clauses in order and take the first whose test is true. => separates test from body.nested `if`
caseCompare one value against a list of candidates per clause.`cond`
loopA named let: bind the variable, run the body while the test holds, and advance the variable each round.named `let`
dotimesloop with an implicit counter from zero.`loop`

本节尚未翻译成你的语言,暂时以英文显示。欢迎提交翻译。

关于真值

Only #f is false. The number zero, the empty string, nil, and the empty list are all true. This matches R5RS and Clojure, and deliberately does not match Ruby, JavaScript, or Python.

The rule matters more than it looks. A language that treats 0 as falsey makes every numeric result a potential branch, which is why code in those languages needs explicit nil checks that vlip code does not.

本节尚未翻译成你的语言,暂时以英文显示。欢迎提交翻译。

原始函数

FormMeaningDesugars to
arithmeticWhole numbers, with promotion when a float is involved.`+` `-` `*` `/` `%`
comparisonReturn #t or #f.`=` `<` `>` `<=` `>=`
logicNegation. and and or are forms, not primitives, because they short-circuit.`not`
listsBuild and take apart cons cells.`car` `cdr` `cons` `list` `null?`
sequencesTake a procedure and a list, and return a new list.`map` `filter` `fold` `apply`
outputWrite to the machine's output buffer, not straight to a terminal, so a host can capture it.`print` `println`

本节尚未翻译成你的语言,暂时以英文显示。欢迎提交翻译。

尚未实现

let* and rest parameters are written in the examples and do not yet evaluate correctly. Callable keywords do not work either.

The cause of the let* failure is a real design question rather than a typo: [ ] is a vector literal in a value position and a binding group in a form position, and the reader does not yet record which reading applies. It is written up in the roadmap.