(defmacro do-grid [[r rows c cols] & body] ...) — positional names, a [ ] pattern wherever an argument is a vector, and & for the tail. The reading of the list lives in Expand, below both sides that need it: Parse turns it into the bindings a macro body opens with, and Macro checks a call against the same reading before expanding it, so arity and shape are refused with the call's own location rather than with the Loc.from_macro stamp every node of an expansion carries. The breaking half: [args] used to bind the whole argument list and now binds the first argument. The whole list is [& args], and every defmacro in the tree — prelude, vendor, tests, the elisp fixtures — was migrated to it. One grammar, not a legacy mode.
49 lines
1.8 KiB
Plaintext
49 lines
1.8 KiB
Plaintext
;;;; The fixture C-x C-e is tested against: one value of every shape the
|
|
;;;; renderer knows, held in globals so an expression has something real to
|
|
;;;; read out of a running process.
|
|
;;;;
|
|
;;;; It keeps running rather than counting reloads, because a thunk only runs
|
|
;;;; when the program next reaches a frame boundary. (agent/wait 5) is both the
|
|
;;;; poll and the pacing — 5ms of nothing, which is what a frame is when there
|
|
;;;; is no frame.
|
|
(import agent "vendor:agent")
|
|
|
|
(defstruct V [x f32 y f32])
|
|
(defstruct Blob [id i32 name string pos V tags [3 i32]])
|
|
(defenum Colour [red 0 green 1 blue 2])
|
|
|
|
(defvar ticks i64)
|
|
(defvar big u64)
|
|
(defvar b Blob)
|
|
(defvar arr [4 i32])
|
|
(defvar col Colour)
|
|
|
|
;;; Read by nothing on purpose: it is here to be *evaluated*, so that C-x C-e
|
|
;;; is tested against a constant living in the program's memory and not only
|
|
;;; against arithmetic the compiler could have done itself.
|
|
(defconst step-by i64 3)
|
|
|
|
;;; Called by nothing here either, and for the same reason: it is the buffer's
|
|
;;; *own* macro, and what it is for is to be called from an expression typed at
|
|
;;; the editor. A session used to hold the prelude's macros and its imports'
|
|
;;; and not these, so (tenfold 7) was an unknown name in the very file that
|
|
;;; declares it. Nothing in this program names it, so no macro module is built
|
|
;;; for the build itself -- the first one is paid by the evaluation that calls
|
|
;;; it.
|
|
(defmacro tenfold [& args]
|
|
`(* ~(at args 0) 10))
|
|
|
|
(defn main [] i32
|
|
(agent/start "/tmp/flan-printers-fallback.sock")
|
|
(set big 0xFFFFFFFFFFFFFFFF)
|
|
(set (.id b) 7)
|
|
(set (.name b) "sandy \"quoted\"")
|
|
(set (.x (.pos b)) 1.5)
|
|
(set (at (.tags b) 1) 42)
|
|
(set (at arr 2) 9)
|
|
(set col :blue)
|
|
(dotimes [i 4000]
|
|
(agent/wait 5)
|
|
(set ticks (+ ticks 1)))
|
|
0)
|