source: project/release/4/cells/trunk/cells.scm @ 31167

Last change on this file since 31167 was 31167, checked in by juergen, 6 years ago

cells 1.2 with cell->closure

File size: 967 bytes
Line 
1(module cells (cells cell cell? cell-of? cell-ref cell-set! cell->closure)
2(import scheme
3        (only chicken define-record-type define-record-printer
4              case-lambda getter-with-setter)
5        (only extras fprintf))
6
7(define-record-type cell
8  (cell var)
9  cell?
10  (var cell-ref cell-set!))
11
12(define cell-ref (getter-with-setter cell-ref cell-set!))
13
14(define ((cell-of? type?) xpr)
15  (and (cell? xpr)
16       (type? (cell-ref xpr))))
17
18(define (cell->closure cl)
19  (case-lambda
20    (() (cell-ref cl))
21    ((val) (cell-set! cl val))))
22
23(define-record-printer (cell var out)
24  (fprintf out "!~s!" (cell-ref var)))
25
26(define cells
27  (let ((signatures '((cell init)
28                      (cell? xpr)
29                      (cell-of? ok?)
30                      (cell-ref cl)
31                      (cell-set! cl val)
32                      (cell->closure cl))))
33    (case-lambda
34      (() (map car signatures))
35      ((sym) (assq sym signatures)))))
36
37) ; cells
38
39
40
Note: See TracBrowser for help on using the repository browser.