Skip to content

Commit d8b85e2

Browse files
committed
minor tweaks
1 parent 6954516 commit d8b85e2

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

schedule.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ March
2020

2121
14 Spring Break
2222
21 due: Lambda (1 week)
23-
28
23+
28 Lecture topic: inlining
24+
30 Lecture topic: polymorphism
2425

2526
April
2627
---------------------------------------------
2728
4 due: Type Dynamic, Dynamic Typing (2 weeks)
28-
29+
Lecture topic: ??
2930

3031

3132

@@ -39,7 +40,7 @@ Student Projects
3940
* lazy evaluation
4041
* gradual typing
4142
* self hosting
42-
* tail call optimization
43+
* tail call optimization (Michael lecture April 11)
4344
* I/O
4445
* foreign function interface
4546
* quasi-quote and unquote

vectors.rkt

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
[`(Vector ,ts ...)
3131
(unless (and (exact-nonnegative-integer? i)
3232
(i . < . (length ts)))
33-
(error 'type-check "invalid index ~a" i))
33+
(error 'type-check "invalid index ~a" i))
3434
(let ([t (list-ref ts i)])
35-
(values `(has-type (vector-ref ,e (has-type ,i Integer)) ,t) t))]
35+
(values `(has-type (vector-ref ,e (has-type ,i Integer)) ,t)
36+
t))]
3637
[else (error "expected a vector in vector-ref, not" t)])]
37-
[`(vector-set! ,e-vec ,i ,e-arg)
38-
(define-values (e-vec^ t-vec) ((type-check env) e-vec))
39-
(define-values (e-arg^ t-arg) ((type-check env) e-arg))
38+
[`(vector-set! ,(app (type-check env) e-vec^ t-vec) ,i
39+
,(app (type-check env) e-arg^ t-arg))
4040
(match t-vec
4141
[`(Vector ,ts ...)
4242
(unless (and (exact-nonnegative-integer? i)
@@ -51,13 +51,11 @@
5151
[else (error 'type-check
5252
"expected a vector in vector-set!, not ~a"
5353
t-vec)])]
54-
[`(eq? ,e1 ,e2)
55-
(let-values ([(e1 t1) ((type-check env) e1)]
56-
[(e2 t2) ((type-check env) e2)])
57-
(match* (t1 t2)
58-
[(`(Vector ,ts1 ...) `(Vector ,ts2 ...))
59-
(values `(has-type (eq? ,e1 ,e2) Boolean) 'Boolean)]
60-
[(other wise) ((super type-check env) e)]))]
54+
[`(eq? ,(app (type-check env) e1 t1) ,(app (type-check env) e2 t2))
55+
(match* (t1 t2)
56+
[(`(Vector ,ts1 ...) `(Vector ,ts2 ...))
57+
(values `(has-type (eq? ,e1 ,e2) Boolean) 'Boolean)]
58+
[(other wise) ((super type-check env) e)])]
6159
[else ((super type-check env) e)])))
6260

6361
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

0 commit comments

Comments
 (0)