Stable extension point for definition-form? — no monkey-patching
Replace the fragile pattern of capturing and wrapping definition-form? with a mutable *definition-form-extensions* list in render.sx. Web modules append names to this list instead of redefining the function. Survives spec reloads without losing registrations. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -213,27 +213,22 @@
|
||||
|
||||
|
||||
;; --------------------------------------------------------------------------
|
||||
;; Patch form-classification functions
|
||||
;; Register web forms with adapters
|
||||
;;
|
||||
;; The adapters (html, sx, dom, async) use classifier functions to decide
|
||||
;; how to handle forms during rendering. Now that these web forms are
|
||||
;; registered as custom special forms, we redefine the classifiers to
|
||||
;; include them. This runs after all adapters are loaded.
|
||||
;; Appends form names to the extension lists that definition-form?,
|
||||
;; render-html-form?, special-form? etc. check. No function wrapping —
|
||||
;; survives spec reloads.
|
||||
;; --------------------------------------------------------------------------
|
||||
|
||||
(define WEB_FORM_NAMES
|
||||
(list "defhandler" "defpage" "defquery" "defaction" "defrelation"))
|
||||
|
||||
;; Redefine definition-form? to include web forms.
|
||||
;; All adapters call this to identify "eval for side effects" forms.
|
||||
(let ((core-definition-form? definition-form?))
|
||||
(define definition-form?
|
||||
(fn (name)
|
||||
(or (core-definition-form? name)
|
||||
(contains? WEB_FORM_NAMES name)))))
|
||||
;; Extend definition-form? via the stable extension point in render.sx
|
||||
(for-each (fn (name)
|
||||
(append! *definition-form-extensions* name))
|
||||
WEB_FORM_NAMES)
|
||||
|
||||
;; Extend adapter form-name lists so dispatchers recognise web forms.
|
||||
;; These lists are mutable — append! adds to them in place.
|
||||
(for-each (fn (name)
|
||||
(append! RENDER_HTML_FORMS name)
|
||||
(append! SPECIAL_FORM_NAMES name))
|
||||
|
||||
Reference in New Issue
Block a user