Packages
rontolisp has a small namespace (package) system with a set of built-in packages, plus user-defined packages via defpackage:
cl— the standard package. All built-in functions, macros, special forms and the*package*variable belong here.cl-user— the default working package. It usescl, so standard symbols are available unqualified. The current package when a program starts. User definitions go here.rontolisp— a package for implementation-specific symbols. It does not usecl. It owns theversion,list-functions,list-macrosandlist-special-formsfunctions.linalg— numpy-style vector/matrix operations (linalg:zeros,linalg:matmul,linalg:solve, ...), implemented once in Lisp source and available in every backend. It does not usecl. See the Vectors & Matrices guide.java— Java interop by reflection, usable only under the JVM interpreter (java -jar rontolisp.jar), not the compilers or the native binary. It does not usecl. It ownsnew,call,static,fieldandproxy; see the Java interop guide.asdf— a limited, API-compatible subset of ASDF (system definitions):defsystemandload-system. It does not usecl. See the Systems guide.ql— a limited, API-compatible subset of Quicklisp:quickloaddownloads a system from the real Quicklisp distribution and loads it through theasdfsubset.quicklispis a built-in nickname. It does not usecl. See the Systems guide.usocket— a usocket-compatible shim over therontolisp:tcp-*socket built-ins (usocket:socket-connect,usocket:socket-listen, ...), implemented once in Lisp source; also registered as the built-in ASDF system"usocket". It does not usecl. See the TCP Sockets guide.
A symbol can be referenced with a package qualifier: package:symbol (e.g. cl:car, rontolisp:version) reaches the package's external (exported) symbols, and package::symbol reaches any of its symbols, internal ones included — the same single/double colon distinction as Common Lisp (see External and internal symbols). *package* evaluates to the name of the current package, and (in-package name) switches it (the name is a keyword, a symbol, or a string: :rontolisp, rontolisp, "rontolisp"). The standard Common Lisp names common-lisp and common-lisp-user are built-in nicknames for cl and cl-user, so portable (:use #:common-lisp) clauses and common-lisp:car references resolve; user packages can register their own nicknames with the defpackage :nicknames clause.
rontolisp:version returns the same information as rontolisp --version, as a property list.
Because the rontolisp package does not use cl, standard symbols must be qualified with cl: inside it, while version (which it owns) is available unqualified:
(in-package rontolisp)
(cl:print (version)) ; the rontolisp package owns version
(cl:print (cl:car '(1 2))) ; standard symbols need the cl: prefix here
;; (car '(1 2)) would be an error: Undefined symbol: car (use cl:car)
The default package cl-user is empty and uses cl, so ordinary programs do not need any qualifiers.
External and internal symbols
As in Common Lisp, each package distinguishes its external (exported) symbols from its internal ones, and the two qualifier spellings differ in reach:
package:symbol(single colon) references an external symbol only.package::symbol(double colon) references any symbol of the package, internal ones included.
The built-in packages export their entire documented API: every standard cl
symbol is external, and so are all the rontolisp and java functions in this
manual (so the double colon is never required for them, though
rontolisp::version is also accepted and means the same as
rontolisp:version). Internal symbols follow the % prefix convention — for
example rontolisp::%json-parse, the fixed-arity helper behind
rontolisp:json-parse — and are
implementation details that may change without notice. cl-user exports
nothing, like the Common Lisp COMMON-LISP-USER package, so on the rare
occasion a cl-user symbol needs a qualifier it is written cl-user::name.
A single-colon reference to a non-external symbol is an error at read/compile time:
> (rontolisp:%json-parse "1" nil)
Error: The symbol %json-parse is not external in the rontolisp package (use rontolisp::%json-parse)
There is no runtime export function — a package's export set is fixed when
it is defined: the built-in packages export their documented API, and a
user-defined package exports its (:export ...) clause (see
Missing features). A symbol defined
while (in-package rontolisp) is in effect is interned into the rontolisp
package as an internal symbol, so from other packages it must be referenced
with the double colon.
User-defined packages (defpackage)
New packages are defined with defpackage:
Like in-package, defpackage is a literal, top-level directive consumed at
read/compile time, so packages are defined in source order, before any use.
The supported clauses are (:use package...), (:export symbol...),
(:nicknames name...) and (:import-from package symbol...), plus
(:documentation "...")/(:size n) which are accepted and ignored; the name
and the clause arguments are keywords, bare symbols, strings, or uninterned
symbols (#:name, the portable defpackage idiom). :shadow and
:shadowing-import-from are errors (rontolisp has no symbol shadowing), and so
is any other clause, redefining an existing package, or using a package that
does not exist yet.
:usemakes the external symbols of the used packages visible unqualified, as in Common Lisp — internal symbols of a used package still need the double colon. Without a:useclause nothing is inherited (like SBCL), soclsymbols would need thecl:prefix; ordinary packages should say(:use :cl)(or, portably,(:use #:common-lisp)). When several used packages export the same name, the first package in:useorder wins (Common Lisp signals a conflict instead).:exportdeclares the package's external symbols. Symbols interned later (adefununder(in-package name)that is not in the:exportclause, a free variable) are internal, exactly like the built-in packages.:nicknamesregisters alternate names that resolve everywhere the canonical name does (in qualifiers,in-package,:use, ...). A nickname colliding with an existing package or nickname is an error.:import-frommakes the named symbols of one package visible unqualified without using the whole package. Resolution is textual: an imported name resolves to the source package's canonical spelling, so importing and then re-exporting a symbol makesmypkg:namerefer to the original definition.
There is no runtime package manipulation: make-package, export, import,
use-package, find-package and friends are not available, and a defpackage
inside another form (not top-level) is an error.
Package introspection
rontolisp:list-functions, rontolisp:list-macros and rontolisp:list-special-forms return the symbols of a package by category, sorted alphabetically. The optional argument is a package designator — a keyword, a bare symbol, a quoted symbol or a string (:cl, cl, 'cl, "cl") — and defaults to :cl. An unknown package is an error (No such package: foo).
The classification follows the function namespace: a name is listed as a function exactly when it is usable as a function value via #'name (so first, length, 1+, ... are functions even though they compile via inline expansion), and list-macros/list-special-forms list the operators that have no function value. Notes:
list-functionsofcl-userlists the user-defined functions (defuns); names that are package-qualified,%-prefixed internals or shadow aclsymbol are excluded. In compiled output it is a compile-time snapshot of the program'sdefuns — functions defined at runtime throughload/eval(even with--dynamic) are not included, and functions defined while(in-package :rontolisp)is in effect are not listed for any package.list-functionsof a user-defined package lists the package'sdefuns under their canonical qualified names —mypkg:fnfor an exported function,mypkg::fnfor an internal one.list-macrosandlist-special-formsof a user package arenil.- Car/cdr compositions (
cadr,caddr, ...) are recognized by pattern, not enumerated, so they do not appear inlist-functions. - The package designator must be a literal; a computed designator is rejected at read/compile time (the interpreter additionally accepts a computed designator through
funcall, where an unknown package yieldsnilinstead of an error — user packages are known only at read/compile time). - Like
version, these functions are not supported inside the compiled runtimeeval/load.
Packages are resolved at read/compile time (in source order), so in-package is a top-level directive and *package* reflects the current package rather than being a mutable runtime variable. In compiled output a runtime-loaded file's package directives are not processed; the rontolisp package's functions (version, list-functions, ...) are not available as first-class values (they cannot be passed to mapcar/funcall); and a cl symbol name must not be shadowed as a local variable inside a package that does not use cl.
rontolisp Package Extensions
The symbols the rontolisp package owns are implementation-specific and not
part of Common Lisp. They must be referenced with the rontolisp: qualifier
(or used unqualified after (in-package rontolisp)). Besides the introspection
helpers above (version, list-functions, list-macros, list-special-forms),
the package provides asynchronous outgoing HTTP via rontolisp:fetch (which
returns a promise) together with the generic promise operations
rontolisp:await (resolve, blocking), rontolisp:then (chain a callback) and
rontolisp:promisep (type predicate), and JSON conversion via
rontolisp:json-parse /
rontolisp:json-stringify
(JavaScript JSON.parse/JSON.stringify style). All of these have their own
pages in the Functions reference,
including the full rontolisp:fetch /
rontolisp:await /
rontolisp:then /
rontolisp:promisep documentation.