Commitc9d7e419Recorded13 Jan 2026Repositorysigil-css
macro: Fix library macro access to internal helper functions
Message
Syntax-rules macros in libraries capture helper function values at macro definition time. If a helper is defined after the macro in source order, its value is still #f when the macro captures it.
Fixes: - css.sgl: Move value helpers (%prop-name->string, %value->string, %values->string) before the css macro that uses them - async.sgl: Move %run-async before with-async macro
Also includes pattern matching improvements to preserve syntax wrappers on pattern variable bindings for better hygiene metadata flow.
Changed
src/sigil/css.sgl | 50 ++++++++++++++++++++++++++++----------------------
1 file changed, 28 insertions(+), 22 deletions(-)Diff
src/sigil/css.sglmodified
@@ -150,6 +150,33 @@
150
(and (pair? x) (eq? (car x) 'raw))) 151
152
+153
;; ========== Value Helpers ==========+154
;; NOTE: These must be defined before macros that use them.+155
;; Macros capture helper values at definition time, so helpers+156
;; must be fully defined before the capturing macro.+157
+158
;; Convert property name (symbol or string) to string+159
;; % prefix = exported for macro hygiene+160
(define (%prop-name->string name)+161
(if (symbol? name)+162
(symbol->string name)+163
name))+164
+165
;; Convert a single value to string+166
;; % prefix = exported for macro hygiene+167
(define (%value->string v)+168
(cond+169
((string? v) v)+170
((number? v) (number->string v))+171
((symbol? v) (symbol->string v))+172
(else (format "~a" v))))+173
+174
;; Convert multiple values to space-separated string+175
;; % prefix = exported for macro hygiene+176
(define (%values->string vals)+177
(string-join (map %value->string vals) " "))+178
+179
180
;; ========== Rule Constructors ========== 181
182
;;; Main CSS rule constructor (macro version)@@ -485,28 +512,7 @@
512
theme))) 513
514
−488
;; ========== Value Helpers ==========−489
−490
;; Convert property name (symbol or string) to string−491
;; % prefix = exported for macro hygiene−492
(define (%prop-name->string name)−493
(if (symbol? name)−494
(symbol->string name)−495
name))−496
−497
;; Convert a single value to string−498
;; % prefix = exported for macro hygiene−499
(define (%value->string v)−500
(cond−501
((string? v) v)−502
((number? v) (number->string v))−503
((symbol? v) (symbol->string v))−504
(else (format "~a" v))))−505
−506
;; Convert multiple values to space-separated string−507
;; % prefix = exported for macro hygiene−508
(define (%values->string vals)−509
(string-join (map %value->string vals) " "))+515
;; ========== Property Helpers ========== 516
517
;;; Explicit property constructor (rarely needed). 518
;;;