v1.0.0 — Stable release + TUI support #8
12
org/slot.org
12
org/slot.org
@@ -93,8 +93,8 @@ the first call and frozen for subsequent calls:
|
||||
|
||||
The ~render-fn~ itself is returned so callers can use it inline.
|
||||
|
||||
The mode parameter is accepted but only respected on the first
|
||||
registration for a slot. This prevents a later registration from
|
||||
The mode parameter is validated on first call via ~assert~ and then
|
||||
frozen for subsequent calls. This prevents a later registration from
|
||||
changing the slot's semantics out from under earlier registrations.
|
||||
|
||||
#+BEGIN_SRC lisp :tangle ../src/components/slot.lisp
|
||||
@@ -102,10 +102,14 @@ changing the slot's semantics out from under earlier registrations.
|
||||
(let* ((key (string name))
|
||||
(slot (gethash key *slots*)))
|
||||
(if (null slot)
|
||||
;; First registration — set mode and create entry
|
||||
;; First registration — validate and set mode, create entry
|
||||
(progn
|
||||
(assert (member mode '(:stack :replace :single-winner)) ()
|
||||
"Invalid slot mode: ~S (use :stack, :replace, or :single-winner)"
|
||||
mode)
|
||||
(setf (gethash key *slots*)
|
||||
(list :mode mode
|
||||
:entries (list (cons order render-fn))))
|
||||
:entries (list (cons order render-fn)))))
|
||||
;; Existing slot — respect frozen mode
|
||||
(let ((entries (getf slot :entries)))
|
||||
(ecase (getf slot :mode)
|
||||
|
||||
@@ -8,10 +8,14 @@ Each entry: (:mode <mode> :entries <(order . render-fn) list>).")
|
||||
(let* ((key (string name))
|
||||
(slot (gethash key *slots*)))
|
||||
(if (null slot)
|
||||
;; First registration — set mode and create entry
|
||||
;; First registration — validate and set mode, create entry
|
||||
(progn
|
||||
(assert (member mode '(:stack :replace :single-winner)) ()
|
||||
"Invalid slot mode: ~S (use :stack, :replace, or :single-winner)"
|
||||
mode)
|
||||
(setf (gethash key *slots*)
|
||||
(list :mode mode
|
||||
:entries (list (cons order render-fn))))
|
||||
:entries (list (cons order render-fn)))))
|
||||
;; Existing slot — respect frozen mode
|
||||
(let ((entries (getf slot :entries)))
|
||||
(ecase (getf slot :mode)
|
||||
|
||||
Reference in New Issue
Block a user