environments are now hashmaps

This commit is contained in:
FelixBrendel
2019-09-30 08:27:23 +02:00
parent beb4e18efc
commit 2882f81e13
9 changed files with 120 additions and 113 deletions
+7 -7
View File
@@ -57,7 +57,7 @@ condition is false."
(if (= (first (first clauses)) 'else)
(begin
(if (not (= (rest clauses) ()))
(error "There are additional clauses after the else clause!")
(error :syntax-error "There are additional clauses after the else clause!")
(pair 'begin (rest (first clauses)))))
`(if ,(first (first clauses))
(begin @(rest (first clauses)))
@@ -72,7 +72,7 @@ condition is false."
(if (= (first (first clauses)) 'else)
(begin
(if (not (= (rest clauses) ()))
(error "There are additional clauses after the else clause!")
(error :syntax-error "There are additional clauses after the else clause!")
(pair 'begin (rest (first clauses)))))
`(if (member? ,var ',(first (first clauses)))
(begin @(rest (first clauses)))
@@ -119,7 +119,7 @@ condition is false."
`(when ,(first (rest body)) ,(rec (rest (rest body)))))
((= (first (rest body)) 'yield)
(first (rest body)))
(else (error "Not a do-able expression"))))
(else (error :syntax-error "Not a do-able expression"))))
(rec body))
@@ -151,7 +151,7 @@ ithe sequence as arguemens."
(symbol->string orig-export-name)))))
`(define ,export-name
,(mytry (eval orig-export-name)
(error "The module does not contain" orig-export-name)))))
(error :module-error "The module does not contain a key it tries to export")))))
exports))))
@@ -181,7 +181,7 @@ ithe sequence as arguemens."
(desired-type (first (rest objs))))
(if (= actual-type desired-type)
(inner (rest (rest objs)))
(error "type missmatch" actual-type desired-type)))))
(error :type-missmatch "type missmatch" actual-type desired-type)))))
(inner objs))
(define (number? x)
@@ -288,14 +288,14 @@ with (pair elem nil)."
(define (sublist-starting-at-index seq index)
(cond ((< index 0)
(error "sublist-starting-at-index: index must be positive"))
(error :index-out-of-range "sublist-starting-at-index: index must be positive"))
((null? seq) ())
((= 0 index) seq)
(else (sublist-starting-at (rest seq) (- index 1)))))
(define (list-without-index seq index)
(cond ((or (< index 0) (null? seq))
(error "list-remove-index!: index out of range"))
(error :index-out-of-range "list-remove-index!: index out of range"))
((= 0 index) (rest seq))
(else (pair (first seq) (list-without-index (rest seq) (- index 1))))))