-
Notifications
You must be signed in to change notification settings - Fork 0
/
w7-fun.scm
47 lines (31 loc) · 1.08 KB
/
w7-fun.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
; W7 fundamentals -- what all users see.
; Scheme- as defined by AI Memo 1564
; Cells - the primitive side effect.
; We eschew set-car!, vector-set!, etc. because they can too easily
; create accidental communication channels.
(define-record-type cell :cell
(make-cell)
cell?
(value cell-ref cell-set!))
(define (new-cell . init-option)
(let ((cell (make-cell)))
(if (not (null? init-option))
(cell-set! cell (car init-option)))
cell))
; Enclose converts a lambda-expression to a procedure.
(define (enclose lambda-exp env)
(if (and (pair? lambda-exp)
(eq? (car lambda-exp) 'lambda))
(eval lambda-exp env)
(error "arg to enclose wasn't a lambda-expression" lambda-exp env)))
(define (control hunoz whatnot)
(error "arg to CONTROL isn't a known hardware I/O device" hunoz))
; Rights amplification - built into Scheme 48.
(define (new-seal)
(make-record-type 'sealed '(obj)))
(define (seal obj s)
((record-constructor s '(obj)) obj))
(define (unseal z s)
((record-accessor s 'obj) z))
(define (sealed? candidate s)
((record-predicate s) candidate))