destructuring compliance, deps.edn comments, clojure.java.io shim
Destructuring (drove by trying to load Selmer):
- defmacro params now destructure like fn (parse-params + destructure-bind), so
[& [a & more :as all]] and {:keys ...} work in macro arglists.
- map-destructuring a sequential value treats it as keyword args (alternating
k/v, or a trailing map) — the [& {:keys [...]}] form, in fns and macros.
- :keys/:syms accept namespaced symbols (x/y): looks up the namespaced key,
binds the bare local.
deps.edn: read with Jolt's reader instead of Janet's parse, so EDN ';' line
comments are handled (Janet treats ';' as splice).
clojure.java.io: the shim was at clojure/java_io.clj (ns clojure.java-io, never
the clojure.java.io that code requires) and used bare-qualified Janet calls that
the janet.* bridge no longer resolves. Moved to clojure/java/io.clj and rewritten
on janet.file/os: file/reader/writer/resource/copy/delete-file/make-parents.
Specs in destructuring-spec; destructuring note in the ebnf.
This commit is contained in:
parent
48a5f6258f
commit
41f78e218f
6 changed files with 132 additions and 60 deletions
|
|
@ -162,3 +162,21 @@ feature = ":clj" | ":cljs" | ":default" | keyword ;
|
|||
(* Tagged literal: #tag form. Built-in tags include #inst and #uuid; others
|
||||
dispatch to a registered data-reader (else error). *)
|
||||
tagged-literal = "#" , symbol , ws , form ;
|
||||
|
||||
(* ── Destructuring (semantics, not reader syntax) ────────────────────────────
|
||||
The reader produces plain vectors and maps; the binding forms (let, fn, loop,
|
||||
doseq, for, defmacro params, …) interpret them as destructuring patterns:
|
||||
|
||||
binding = symbol | seq-binding | map-binding ;
|
||||
seq-binding = "[" , { binding } , [ "&" , binding ] , [ ":as" , symbol ] , "]" ;
|
||||
map-binding = "{" , { binding , form (* {local key} *)
|
||||
| ":keys" , "[" {symbol} "]" (* x or ns/x *)
|
||||
| ":strs" , "[" {symbol} "]"
|
||||
| ":syms" , "[" {symbol} "]"
|
||||
| ":or" , map (* defaults *)
|
||||
| ":as" , symbol } , "}" ;
|
||||
|
||||
A symbol in :keys/:syms may be namespaced (x/y): the namespaced key is looked
|
||||
up but the local is the bare name (y). Destructuring a *sequence* with a
|
||||
map-binding treats it as keyword args (alternating k v, or a trailing map) —
|
||||
this is the fn/macro `[& {:keys [...]}]` form. *)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue