Categorygithub.com/rasteric/z3s5-lisp
modulepackage
2.4.3+incompatible
Repository: https://github.com/rasteric/z3s5-lisp.git
Documentation: pkg.go.dev

# README

Z3S5 Lisp

"I want my 1980s Lisp!"

Z3S5 GoDoc Go Report Card

Usage

Check out the basic lisp interpreter z3.go in folder cmd/z3/ for an example of how to use Z3S5 Lisp in the Go language. You may also use the interpreter from the command line by running the z3 binary. There is a version with GUI support in z3g.go in folder cmd/z3g/. This integrates Fyne for building graphical user interfaces. The startup with GUI is a bit more complicated since the GUI loop runs concurrently. You can find an example in z3g.go. See the file cmd/z3g/demo.lisp for GUI demos. You need to (exit) the interpreter after running a demo since currently ending a demo ends the GUI thread. This will be fixed in the future.

There is a build tag nosound you may use to leave out sound support. If this option is not specified, then the beep command produces a few basic sounds which are embedded into the executable and do slightly increase its size.

Building

Go 1.22+ is required.

Linux: Alsa sound support development library libasound2 needs to be installed with apt get install libasound2 on Debian-based distributions. For the manuals both pandoc and the Eisvogel Pandoc Template are required. Notice that normal make will attempt to compile these manuals. You may use make lisp in directory cmd/z3 to only compile the z3 sample executable if you want to test it without generating manuals.

Windows: This has not been tested on Windows but should work as long as your machine satisfies the compilation requirements for the Beep sound library or if you use build tag nosound.

MacOS: Not tested so far; building should be similar to Linux.

Z3S5 Lisp Reference

A rudimentary user manual can be found in directory docs/usermanual and PDF and HTML can be generated using the accompanying makefile if pandoc is installed on your system. A very large reference manual can be generated by using the makefile in the main directory or make docs in directory cmd/z3 once the z3 executable has been built.

Online help: You may use (dump [prefix]) in the Lisp system to get a list of toplevel bindings, (help symbol) without quote to get information about a function, global symbol, or macro. To get a list of help topics use (help-topics) and (help-about topic) provides a list of symbols for a help topic. Notice that GUI commands are only available when Z3S5 Lisp was compiled with GUI support, as illustrated in cmd/z3g/z3g.go.

Z3S5 Lisp is an old-fashioned Lisp-1 dialect originally based on Nukata Lisp by SUZUKI Hisao. It uses real cons cells and is reasonably fast for an interpreter. (Depending on your mileage, it's definitely not optimized for speed.) There are some notable differences to other Lisps:

  • Iterators over sequences use the order (iterator sequence function), not sometimes one and sometimes the other. Exception: memq and member ask whether an element is a member of a list and have order (member element list).

  • There is no meaningful eq, equality is generally tested with equal?.

  • Predicate names generally end in a question mark like in Scheme dialects except for = for numeric equality. Example: equal?. There is no p-suffix like in other Lisps.

  • dict data structures are very powerful and multi-threading safe.

  • There is experimental support for concurrency with green threads (aka goroutines).

Please don't complain it's not Common Lisp or R7RS Scheme! Z3S5 Lisp is deliberately a somewhat arcane, old-fashioned language mostly used for experimentation in a forthcoming retro-style virtual Lisp machine and as an extension language for my own software projects.

License

Permissive MIT License. Happy hacking! :smile_cat:

# Packages

Package actions contains helper functions for implementing actions (plugins) in a program using Z3S5 Lisp.
No description provided by the author
No description provided by the author

# Functions

ArrayToList converts an array (Go slice) to a list.
AsLispBool returns a given Go bool as a Lisp bool, i.e., using Nil for false.
Btoi returns the uint64 from an 8-byte big endian representation.
ConvertIntsToNumbers converts any Int64 integer values in a slice to goarith.Int64 values, modifying the array.
ConvertNumbersToInts converts any goarith.Int32 and goarith.Int64 values in a slice of interface{} values to Int64, modifying the array.
ConvertTimeToDateList converts a time.Time value into a Lisp datelist.
copyDict copies a Dict deeply.
copyMap copies a interface{} map deeply.
dictToArray converts a dict (Go map) to an array.
ExpectBoxed returns a boxed value of type sort if a is one and true, nil and false otherwise.
GetAsRune returns a rune given a string or goarith.Number representing a char and returns it, raises an error otherwise.
GetGID returns the current goroutine's ID.
Itob returns an 8-byte big endian representation of an uint64.
ListToArray converts a list into an array (Go slice).
MaxInt returns the larger of two ints, the first argument if they are equal.
MinInt returns the smaller of two ints, the first argument if they are equal.
MustGetBoxed returns a boxed value of type sort or panics.
No description provided by the author
No description provided by the author
No description provided by the author
NewBoxedArray returns a new empty array for boxed items.
NewBufferedReader returns a buffered reader based on an io.Reader.
NewBuiltInFunc constructs a BuiltInFunc.
NewClosure constructs a Closure.
NewEvalError constructs an EvalError.
No description provided by the author
No description provided by the author
NewInterp constructs an interpreter and sets built-in functions etc.
NewLambda constructs a Lambda.
NewMacro constructs a Macro.
NewNotVariableError constructs an EvalError which indicates an absence of variable.
NewPermissions creates a set of permissions from an array of symbolic strings.
NewProtectedVariableError constructs an EvalError which indicates that the given variable is protected against global mutation.
NewReader constructs a reader which will read Lisp expressions from r.
NewSeeker returns a new Seeker based on given io.Seeker.
No description provided by the author
NewSym constructs an interned symbol for name.
NewSym2 constructs an interned symbol (or an expression keyword if isKeyword is true on its first construction) for name.
NewWriter returns a new lisp writer.
NewWriterAt creates a new WriterAt for writing to particular positions.
QqExpand expands x of any quasi-quote `x into the equivalent S-expression.
QqQuote quotes x so that the result evaluates to x.
reverse array returns an array reversed as copy.
reverse a string.
Same is true if two Lisp interface{} have the same values, false otherwise.
SleepNS blocks for duration and then returns.
Str returns a textual representation of any Lisp expression x.
Str2 returns a textual representation of any Lisp expression x.
StrArrayToList converts an array of strings (not a Lisp object) to a list of strings (an admissible Lisp object).
ToBool takes a Lisp bool and returns a Go bool.
No description provided by the author
ToInt attempts to convert a value to the native int value, panicking if the value does not fit into an int.
ToInt64 attempts to convert a value to int64.
ToMaybeUInt64 attempts to convert a value to uint64.
ToUint16 converts a value to uint16.
ToUInt32 converts a value to uint32.
ToUInt8 convert a value to uint8.

# Constants

default max buffer size.
default buffer size for reader.
Z3S5 Machine draw text in vram - unused in Z3S5 Lisp.
*never used*.
Z3S5 Machine editor load hook - unused in Z3S5 Lisp.
Z3S5 Machine editor load text hook - unused in Z3S5 Lisp.
Z3S5 Machine print text in editor - unused in Z3S5 Lisp.
Z3S5 Machine editor save hook - unused in Z3S5 Lisp.
Z3S5 Machine editor save text hook - unused in Z3S5 Lisp.
Z3S5 Machine after scrolling down - unused in Z3S5 Lisp.
Z3S5 Machine before scrolling down - unused in Z3S5 Lisp.
Z3S5 Machine after scrolling up - unused in Z3S5 Lisp.
Z3S5 Machine before scrolling up - unused in Z3S5 Lisp.
Z3S5 Machine set cursor position in vram - unused in Z3S5 Lisp.
just before the system shuts down.
general slow IRQ (ca.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
called after the system has been started (all init files loaded).
very slow (only every few minutes).

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Boxed types (mostly handled externally).
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
EofToken is a token which represents the end of file.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
FullPermissions are the default full permissions of a machine, allowing full access to all resources of the machine.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Nil is a nil of type *Cell and it represents the empty list.
No description provided by the author
No description provided by the author
Prelude is an initialization script of Lisp.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SafeSilentPermissions are minimal permissions without sound, graphics, and file access but with prefs read access and console.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

Arg represents a bound variable in a compiled lambda/macro expression.
BasicAudio plays a small number of predefined system sounds.
BasicEditor provides only basic string entering for a REPL.
BasicRuntime is a minimal runtime system that only uses the console and basic sounds.
Boxed is the type of an opaque, non-writable Lisp object.
BoxedArray is a synchronized array of boxed items.
BufferedReader is a buffered reader.
BuiltInFunc represents a built-in function.
Cell represents a cons cell.
Closure represents a compiled lambda expression with its own environment.
SimpleColor is to simpify 8-bit color handling.
No description provided by the author
EvalError represents an error in evaluation.
Func is a common base type of Lisp functions.
Future represents a "promise" for future/force.
Interp represents a core of the interpreter.
Lambda represents a compiled lambda expression (within another function).
Macro represents a compiled macro expression.
No description provided by the author
Reader represents a reader of Lisp expressions.
Seeker is a minor abstraction wrapper for io.Seeker.
No description provided by the author
Stream is a Lisp wrapper for a lisp stream, reader and writer.
Sym represents a symbol (or an expression keyword) in Lisp.
ValueHolder is a miscellaneous structure to hold interface{} values with symbols as keys.
Writer is the counterpart to Reader for writing lisp expressions to streams.
WriterAt is a writer that can write to particular positions.

# Interfaces

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author