Language reference

spork-lang 0.6.0

Complete semantics for Spork 0.6.0 lexical and reader syntax, forms, functions, types, namespaces, and Python interoperability.

Spork is a Lisp dialect hosted on CPython. It compiles forms to Python AST, uses Python objects and exceptions directly, and supplies Lisp syntax, macros, and persistent collections.

Use the pages in this section as the language contract for Spork 0.6.0. Start with lexical syntax for tokens and literals, then reader macros for every prefix transformation. For a shorter introduction, use the language tour. Standard functions and collection operations are documented separately in the standard library reference.

Execution model#

Spork keeps Python’s object model, exceptions, modules, call conventions, and runtime tooling. Lisp forms provide expression-oriented control flow, immutable collection literals, destructuring, macros, protocols, and explicit tail recursion.

Feature summary#

FeaturePythonSporkImplementation
Tail RecursionNo built-in optimizationExplicit loop/recurCompiles to a loop
Data StructuresMutable and immutable built-insPersistent collection literalsspork-pds tries and trees
Conditionalsif/elif/else, matchif, cond, matchCompiles to Python control flow
MetaprogrammingDecorators, metaclassesMacros and decoratorsAST transformation
Variable ScopeFunction, global, and nonlocalPython scopes plus lexical let bindingsScoped helper functions when needed
Function ArityDefaults and variadic parametersDefaults, variadic parameters, and multi-arity clausesPython signatures or runtime dispatch
DestructuringSequence unpacking and patternsNested vector and map patternsRecursive assignment or pattern tests
Importsimport/fromns with :require and :importMacro discovery for required Spork namespaces
ProtocolsABCs and duck typingdefprotocolRuntime dispatch table
Batch MutationMutable built-in collectionstransient/persistent!Controlled mutable views