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