Concept
Common Lisp and CLOS
Why Mora is built from generic functions, classes, and macros in a running Lisp image, and what "metaobject" means at each level of the system.
On this page
Common Lisp is not only a notation host for Mora. It supplies the working environment in which the language is developed and performed, and the Common Lisp Object System (CLOS) supplies its extension mechanisms. This page explains how those pieces divide the work and how far the resulting protocol reaches.
Mora’s terse pattern notation is embedded in Common Lisp. Functions, variables, macros, exact ratios, objects, and generic functions are available in the same running image as the patterns. When a composition needs to become a new instrument or language feature, ordinary functions, macros, classes, generic functions, and the inspector are already available.
Mora retains a designated set of semantically operative evaluated constructs as CLOS objects, and its scheduler and tools obtain behavior through open protocols. Extending the system can mean defining another pattern class or specializing a protocol method, rather than adding another case to a central list of recognized types.
defpattern and deftransform provide concise extension routes; they are not the only routes. See Extending Mora.
In CLOS, a generic function can have methods specialized for different classes. Mora uses this to separate concerns such as temporal interpretation, structural observation, construction, composition policy, and shader emission.
An extension can implement the operation it actually needs. A pattern can define a temporal query strategy; an annotation can select a merge policy; a visual operator can add shader interpretation. Each is a separate operation.
Functional representations can also support arbitrary-span queries and sophisticated pattern operators. Mora chooses named classes and generic operations so that representation, strategy, and state can be inspected and specialized in the running image.
Pattern literals and channel forms use Common Lisp macros to make repeated musical actions concise. Literal contexts can interpret symbols as sample names or values, while an explicit ($ expression) escape returns to ordinary Lisp evaluation. See Pattern literals.
Macros are an authoring mechanism: a concise form does not guarantee that every source construct survives as a distinct runtime object. See What is and is not retained.
Functions, classes, and methods can be defined while working. Studio provides a listener, object inspection, documentation, definition navigation, and remote development facilities; see Studio overview and Remote development and performance. Ordinary Lisp variables and functions can hold reusable musical and visual material instead of requiring a separate configuration language; see Scenes and reusable material.
Live redefinition has engineering limits: native graphics resources and concurrent reloads need lifecycle control.
Mora-level pattern objects participate in implementing the pattern language. CLOS classes, generic functions, and method objects implement that object system. Those are different levels of description.
| Level | Examples | Relationship |
|---|---|---|
| Authored pattern program | (>> (s "bd sn") (fast 2)) | Constructs a temporal program. |
| Mora’s retained implementation objects | A speed-pattern instance, events-in, applicable methods | Interpret and expose that temporal program. |
| CLOS implementation facilities | Classes, generic functions, methods | Supply the metalanguage in which Mora is built. |
The important distinction is the level of the protocol. CLOS implements Mora. A Mora pattern object can be a metaobject relative to the pattern language without being a CLOS class metaobject, and without Mora extending the whole CLOS metaobject protocol.
Mora opens selected parts of its pattern-language implementation through an object protocol written in CLOS. Construction helpers and transient transform objects need not all be retained to support that runtime protocol.
| Surface | Representative operations | Scope |
|---|---|---|
| Retained temporal interpretation | events-in | Answers event queries. |
| Structural observation | pattern-children, pattern-summary, pattern-metadata | Supports inspection and tools. |
| Tooling estimate | pattern-period | Estimates visible repetition; it is not an exact metrical clock. |
| Open construction and composition | apply-transform, normalize-clause, apply-clause, pattern-merge-style | Builds and combines behavior; some construction objects are transient. |
| Adjacent visual interpretation | emit-glsl | Applies to the visual-operator subset, not every arbitrary pattern class. |
A few of these surfaces need care:
pattern-periodis a bounded estimate for tools. It is not an exact period and does not substitute for authored meter; see Authored meter and pacing.stackpolyphony is not equivalent to the historical:voicemerge-policy keyword. See Pipelines and composition.emit-glslgives visual operators an adjacent shader interpretation. It applies to the visual-operator subset, not every arbitrary pattern class; see Shader composition.
Source references
Repository-relative paths in the Mora source where these mechanisms are implemented.
-
src/core/pattern.lisp -
src/core/combinators.lisp -
src/mini/defpattern.lisp -
src/mini/deftransform.lisp -
src/mini/transforms.lisp -
src/mini/clauses.lisp