Decision D029 · accepted; details proposed
One dot for members: modules, types, fields
A record of the language's design, as it stood on 2026-11-18: written for the people who build Diaspar, and kept as it was written. Its code is a sketch, not a program of the site, and an older record may show syntax that a later one changed. It names files of the language's source, which is not public yet.
Status: accepted (2026-11-16); it replaces the / separator of D011 and the keyword-function field access of D010 as the main form. Details marked proposed are not yet confirmed.
Decision
a.b means "the member b of a", with one meaning for every kind of a: a module's item, a type's variant or implementation, a record's field, a map's value. A module is the collection of its items, a type of its variants, a record of its fields, as a file is a struct in Zig and a package is a namespace in Go.
(use std.time)
(use std.term.color [Color])
(def start (time.monotonic)) ; an item of the module time
(style.fg (Color.Red)) ; a variant of the enum Color
(Config.from-json data) ; Config's implementation of from-json
order.customer.address.city ; fields, in a chain
math.pi ; a constant of a module
(map .name users) ; .name alone is the function that reads the field
Rules
a.bis the memberbofa. The expander knows at compile time whatais: a module gives its item, a type its variant or the implementation of an imported protocol method, a record value its field, a map value the value under the keyword:b.- Paths use the dot.
(use std.term.style); a full path works without an import,std.term.style.parse. The filesrc/geom/shapes.diasis the modulegeom.shapes, as in Python and Ferron. Package exports name modules the same way,"geom.shapes.*"(D025). - No ambiguity: a local may not hide a name introduced by
use. In a file with(use std.json),(let [json …] json.parse)is an error, "local json hides module json". Sojson.parsealways means one thing, found from theuselines; Go allows this shadowing silently, Diaspar does not. The rule covers only names the file imports or aliases withuse(accepted, 2026-11-16): a module the file does not import forbids nothing, so a local may be calledtimeorreplwherestd.timeorstd.replis not used. - Fields.
p.x, and chainsorder.customer.address.cityinstead of(-> order :customer :address :city).- A record without the field: a warning at compile time when the record's type is known, and a run-time error, at the same point in the interpreter and the compiler (accepted, 2026-11-16; types only warn, D007, as unknown names in D015).
- A map without the key: an error, not
nil, naming the path (cfg.server.port: no key :port). An optional value is read explicitly:(get cfg :port 8080). - A field holding a function is called as any value:
(p.on-click event).
.namealone is an accessor function,(fn [v] v.name), with the same strict rules:(map .name users), and the field of a call's result,(.hp (player-state)), whicha.bcannot express. 6a. Keywords are not functions (accepted, 2026-11-16): Clojure's(:x m), which returnsnilfor a missing key, is removed, so there is one way to read a field and it is strict. An optional value is read with(get m :x default); a key computed at run time with(get m k)or the strict(fetch m k).- A type is a namespace for its variants (
Color.Red, D010 §3b; a variant without fields is the value itself,(style.fg Color.Red), since §3c of 2026-11-18, for the next migration wave) and for the protocol methods it implements:(Config.from-json data)calls Config's implementation offrom-jsonfrom an imported protocol, as Rust'sConfig::from_json(data); this replaces(json.Codec.from-json Config data)(D010 §5a), which stays valid. If two imported protocols giveConfigafrom-json, it is an error listing both. - Namespaced keywords use the dot too:
:cli.doc,:cli.kind. - No method calls through the dot.
(p.area)does not call the functionareaonp: functions stay functions,(area p)or(Shape.area p), so there is one way to call and no question of whoseareait is. Ifphas no fieldarea, the error says so and shows(area p). This may be revisited.
Reading
- The reader reads
a.b.cas one symbol; the expander splits it at the dots and resolves it by rule 1. - Numbers are unaffected: a token that starts with a digit (or a sign and a digit) is a number, so
1.5and-0.5are numbers..5is not a number; write0.5. - A symbol may not end with a dot or contain two dots in a row;
..and...are reserved. /is an ordinary name, the division function; its full path isstd.core./(proposed spelling).
A dot after a closing bracket (accepted, 2026-11-17)
.name written right after ) (or ], }), with no space, reads the member of that form's value: (peek levels).spec.fields, (load-config).server.port, (first users).name. With a space it is a separate form, as before: (list (f x).y) has one argument, (list (f x) .y) two. This is the rule of a.b (no space) against a .b, extended to a closing bracket; the formatter never adds or removes that space.
- It reads as a node that macros and quoting see, and that prints back as written.
@applies after the member chain, as Rust's*after.:@(f).xis(deref (f).x).(f).items[0]is not indexing:[0]is a list (D008).
Dots and macros (accepted, 2026-11-16)
- The scopes of
a.bbelong to its first segment. Hygiene (D015) resolvesaby the symbol's scopes; the rest are member names looked up insidea, not in scope. A template'sp.xreads the template'sp, and the caller'sp.xthe caller'sp; a template'sjson.parsefindsjsonwhere the macro is defined. - "A local may not hide a module" respects hygiene. It is an error only when the local would actually capture the reference, that is when the scopes allow it to bind the module's name; a local
jsonintroduced by a template never makes the caller'sjson.parsean error. - Code is analyzed after expansion. The reader cannot know what
ais, so it keepsa.bas one symbol, and'a.bis a symbol as data. Structure appears after expansion:p.xbecomes the core form for a field read,json.parsea reference to a global. A macro that analyzes code (free variables, renaming) works on expanded code, as Racket'slocal-expand; this is needed for nested macros anyway.(syntax.segments id)splitsa.b.cinto its parts, and(syntax.member base 'name)buildsbase.namekeeping the scopes ofbase; gluing strings into symbols loses hygiene. - A template reads a field with the accessor form:
`(.port ~cfg), which works for any expression, such as(load-config).~cfg.portunquotes the whole formcfg.port: it is the value ofcfg.portin the macro's own code at expansion time, not a field read in the result.
Macro patterns use & for the rest ([test & body]), not Scheme's ..., so reserving .. and ... does not affect them.
Why
- One concept instead of two. With
/for names and keywords for fields,math/piand(:x p)were different mechanisms for "something inside something". With the dot, a constant of a module and a field of a record are reached the same way, which is what Zig, Go, Python, Kotlin, Swift, and Gleam do. - Modern and familiar: every mainstream language reads
a.bas a member; the field chainorder.customer.address.cityreads as data. - Rule 3 keeps what
/gave: with/, a module path could never be confused with a value. Forbidding a local to hide a module keepsa.bunambiguous for people and agents; editors color modules and locals differently. - Now is the cheapest moment: the code written in Diaspar is about 6,000 lines, rewritten mechanically.
Rejected alternatives
/for names and.reserved (Rust's::and., Clojure, Koka): two separators for "a member of"; the user prefers the dot, and rule 3 removes the ambiguity the split was avoiding.- Gleam's split,
/inusepaths and.in code: two signs for one thing, and a full path becomesstd/term/style.parse. nilfor a missing map key with the dot (JavaScript'sundefined): a misspelled key silently becomesniland fails far away.- A warning when a local's field read spells a module path (
(let [geom …] geom.area)in a file that does not importgeom): the local is the onlygeomthe reader of that file sees, and Python, Go and JavaScript allow such shadowing silently; the dangerous case, a local hiding a module the file imports, is already an error by rule 3 (rejected, 2026-11-16). - Swift's and Zig's
.redwhen the type is known: types are inferred and only warn (D007), so a name cannot depend on an inferred type.
Migration
All .dias code, the reader, the expanders of the bootstrap and of the compiler, and the docs move from / paths and :ns/key keywords to the dot in one change, while no other branch is open.