diff options
| author | 2025-11-04 08:24:27 -0500 | |
|---|---|---|
| committer | 2025-11-04 08:24:27 -0500 | |
| commit | f1c3054215f58b4a4cca3a7716993c273c87ca74 (patch) | |
| tree | 1ee2cad102f87ff65f5ef12eda019c79110792a0 /lib/cuprate/implementation/alist-eq-map.scm | |
| parent | start moving implementation-dependent code into separate libraries (diff) | |
move rewriters to implementation file, make rewriter cycle-detecting
Diffstat (limited to '')
| -rw-r--r-- | lib/cuprate/implementation/alist-eq-map.scm | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/cuprate/implementation/alist-eq-map.scm b/lib/cuprate/implementation/alist-eq-map.scm new file mode 100644 index 0000000..f9841e7 --- /dev/null +++ b/lib/cuprate/implementation/alist-eq-map.scm @@ -0,0 +1,21 @@ +(define (make-eq-map) + (define alist '()) + (define interned-alist '()) + (define counter 0) + (lambda (msg obj) + (case msg + ((contains?) (assq obj alist)) + ((cycle-counter) + (set! interned-alist (cons obj interned-alist)) + (let ((num (cdr (assq obj alist)))) + (string->symbol (string-append + "#" + (number->string num) + "#")))) + ((cycle-used?) (memq obj interned-alist)) + ((intern!) + (set! alist (cons (cons obj counter) alist)) + (set! counter (+ counter 1))) + (else (error 'make-eq-map + "invalid message" + msg)))))
\ No newline at end of file |
