aboutsummaryrefslogtreecommitdiffstats
path: root/lib/csc/flag.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-08-01 19:37:49 -0700
committerRose Hogenson <rhogenson@posteo.net>2022-08-01 19:37:49 -0700
commit25750ee505bd976d3c606200fec7253ad40c46d9 (patch)
tree5984514f625db2f7fa01256adef4d3c7be2e3615 /lib/csc/flag.csc
parentModify the project structure. (diff)
downloadchromatopelma-25750ee505bd976d3c606200fec7253ad40c46d9.tar.zst
Remove mutable globals.
Per a closer reading of R7RS, it's an error to mutate an imported binding with set!. My apologies to Guile when I said they had a bug.
Diffstat (limited to 'lib/csc/flag.csc')
-rw-r--r--lib/csc/flag.csc13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/csc/flag.csc b/lib/csc/flag.csc
index c0a28a8..c26fa90 100644
--- a/lib/csc/flag.csc
+++ b/lib/csc/flag.csc
@@ -38,9 +38,11 @@
(define *parsers* (make-map compare-strings))
- ; I'm working around a Guile bug, which wrongly concludes
- ; that *parsers* is immutable.
- (set! *parsers* *parsers*)
+
+
+ (define (add-parser flag bool? setter)
+ (set! *parsers* (insert *parsers* flag
+ (make-flag bool? setter))))
(define-record-type <flag>
@@ -55,9 +57,8 @@
((define-flag name flag type default)
(begin
(define name default)
- (set! *parsers* (insert *parsers* flag
- (make-flag (eq? type bool-flag)
- (lambda (x) (set! name (type x))))))))))
+ (add-parser flag (eq? type bool-flag)
+ (lambda (x) (set! name (type x))))))))
(define *args* '())