mod: Ext 18 — ergonomic defrule / ruleset surface, 375/375
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 34s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 34s
mod/defrule collects trailing conditions via &rest; mod/ruleset assembles rules. No macro needed — conditions are plain data, fn supports &rest here. Produces structurally identical rules to mk-rule (asserted) and works in the engine unchanged. Closes the roadmap's original defrule surface. +11 tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
16
lib/mod/defrule.sx
Normal file
16
lib/mod/defrule.sx
Normal file
@@ -0,0 +1,16 @@
|
||||
;; lib/mod/defrule.sx — ergonomic rule / ruleset construction.
|
||||
;;
|
||||
;; The roadmap sketched a (defrule action :when conditions) surface. Conditions
|
||||
;; already evaluate to plain data, so this needs no macro — variadic functions
|
||||
;; suffice: mod/defrule collects its trailing condition forms via &rest (dropping
|
||||
;; the explicit outer (list ...)), and mod/ruleset assembles rules the same way.
|
||||
;;
|
||||
;; (mod/ruleset
|
||||
;; (mod/defrule "spam-hide" :hide (list :classification "spam"))
|
||||
;; (mod/defrule "default-keep" :keep))
|
||||
|
||||
(define
|
||||
mod/defrule
|
||||
(fn (name action &rest conds) (mod/mk-rule name action conds)))
|
||||
|
||||
(define mod/ruleset (fn (&rest rules) rules))
|
||||
Reference in New Issue
Block a user