Remove define-cell and define~

This commit is contained in:
Vivianne 2024-10-12 13:30:27 -04:00
parent 83cd9fdbcc
commit b8c368aeb4

View file

@ -7,11 +7,9 @@
#:export (make-cell
cell?
!
define-cell
make-deriv
deriv?
~
define~
if~
make-cell-list
cell-list?
@ -127,9 +125,6 @@
((($ <deriv> cell effect proc))
(! cell))))
(define-syntax-rule (define-cell name value)
(define name (make-cell value)))
(define-record-type <deriv>
(_make-deriv cell effect proc)
deriv?
@ -140,7 +135,7 @@
(set-record-type-printer! <deriv> (lambda (d op) (format op "#<deriv ~s>" (deriv-proc d))))
(define (make-deriv proc)
(define-cell cell #f)
(define cell (make-cell #f))
(define deriv
(_make-deriv cell effect proc))
@ -161,9 +156,6 @@
(define-syntax-rule (~ body ...)
(make-deriv (lambda () body ...)))
(define-syntax-rule (define~ name body ...)
(define name (~ body ...)))
(define-syntax-rule (if~ test consequent alternate)
(let ((test-proc (lambda () test))
(consequent-proc (lambda () consequent))
@ -388,9 +380,9 @@
;; (test-begin "scene")
;;
;; (define-cell a 4)
;; (define-cell b 5)
;; (define~ c (+ (! a) (! b)))
;; (define a (make-cell 4))
;; (define b (make-cell 5))
;; (define c (~ (+ (! a) (! b))))
;;
;; (format #t "c computed as 9\n")
;;
@ -454,9 +446,9 @@
;; (ul
;; ,(~map (lambda (x) `(li ,x)) items))))
;;
;; (define~ renderer (let ((value (render body)))
;; (define renderer (~ (let ((value (render body)))
;; (format #t "\n~a\n\n" value)
;; value))
;; value)))
;;
;; (! b 26)
;;