Dialect definitions and templates
A definition starts with define, a dialect name, a list of parent dialects, and an author. The remaining elements are clauses. The parent list contains symbols. The author can be a symbol or a string.
(define delivery (cbcl) @warehouse
(:resource-requirements ((max-depth 8) (max-expansion-size 256)))
(extend notify (to parcel)
(tell to :parcel parcel))
(shape notify (require :parcel string)))
Here delivery extends the base language. In the template, parcel refers to a parameter. The keyword :parcel stays a field name. Use (lang delivery (notify @desk "A17")) to invoke the verb.
Definition clauses
| Clause | Purpose |
|---|---|
(extend verb (parameters…) template) | Declare a verb and one expansion template. Add :from and :to for a role-scoped verb. |
(type name expression), (shape verb rules…) | Declare field contracts. |
(protocol (then …) …) | Declare permitted causal relationships. |
(:roles (declarations…)), (:causal-locality mode) | Declare participants and the policy for causal evidence. |
(state entries…), (:state-bounds bounds…) | Declare projections and limits for state-bearing messages. |
(:resource-requirements ((max-depth n) (max-expansion-size n))) | Limit expansion. The default depth is 16. The permitted range is 1–64. The default size is 1024. The permitted range is 1–8192. |
(:examples expressions…) | Attach example data to the definition. |
(:hash value) | Declare the integrity hash for the definition. |
(:signature value) or (:signed value) | Supply a dialect signature. |
(:protocol value) | Identify the signature algorithm. The leading colon distinguishes this clause from the causal protocol. |
See Shapes and types, Protocols and roles, and State language for clause arguments.
Template forms
The expander binds parameters by position. In an ordinary template it replaces bound symbols throughout the expression. An unbound parameter symbol stays a symbol.
| Form | Expansion |
|---|---|
(literal expression) | Substitute the bound values into the expression. |
(cond (test body) … (else body)) | Select the first matching branch. If no branch matches and there is no fallback, expansion fails. |
A list of literal or cond forms | Expand the forms in sequence. |
The three tests are (= parameter value), (member parameter (values…)), and (type? parameter type). The type test accepts built-in types. It also accepts agent for an address symbol. Use a local field type in a shape. A nested list in an ordinary template stays data after parameter substitution.
Installation checks
The checks cover recursion (R1), expansion limits (R2), core verb preservation (R3), signatures (R4), shapes and protocols (R5), roles (R6), and state (R7). Configure the applicable signer to check the signature. The installer checks the definition. The host applies its own adoption policy.
Dialect adoption explains that decision. Annotated dialects shows how complete definitions use these clauses.