From c7e47d6bf837e14f13343ee4b5664eb92cdc7492 Mon Sep 17 00:00:00 2001 From: Dane Johnson Date: Sun, 23 Nov 2025 09:13:27 -0600 Subject: [PATCH] I could twiddle like this forever, one last change before compiler --- direct-style-interpreter.scm | 42 +++++++++++++++++------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/direct-style-interpreter.scm b/direct-style-interpreter.scm index b0e8b4f..87d2209 100644 --- a/direct-style-interpreter.scm +++ b/direct-style-interpreter.scm @@ -213,28 +213,26 @@ (define-primitive + + 2) (define-primitive = = 2) (define-initial call/cc - (let* ([arity 1] - [arity+1 (1+ arity)]) - (make-closure - (lambda (v* sr) - (if (= arity+1 (activation-rec-length v*)) - (call/cc ;; call/cc is "magic" for our purposes here, - ;; there are no reified continuations in the denotation - (lambda (k) - (invoke - (activation-rec-ref v* 0) - (let ([rec (make-activation-rec (+ 1 1))]) - (activation-rec-set! - rec 0 - (make-closure - (lambda (values r) - (if (= arity+1 (activation-rec-length values)) - (k (activation-rec-ref values 0)) - (error "Incorrect arity" 'continuation))) - (*env*))) - rec)))) - (error "Incorrect arity" 'call/cc))) - (*env*)))) + (make-closure + (lambda (v* sr) + (if (= (activation-rec-length v*) 2) + (call/cc ;; call/cc is "magic" for our purposes here, + ;; there are no reified continuations in the denotation + (lambda (k) + (invoke + (activation-rec-ref v* 0) + (let ([rec (make-activation-rec 2)]) + (activation-rec-set! + rec 0 + (make-closure + (lambda (values r) + (if (= (activation-rec-length values) 2) + (k (activation-rec-ref values 0)) + (error "Incorrect arity" 'continuation))) + (*env*))) + rec)))) + (error "Incorrect arity" 'call/cc))) + (*env*))) (define-initial apply (make-closure (lambda (v* sr)