Skip to content
This repository has been archived by the owner on Jan 28, 2018. It is now read-only.

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
zaoqi committed Dec 30, 2017
1 parent 5e8ae98 commit c98aa54
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 50 deletions.
17 changes: 11 additions & 6 deletions prelude.scm
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,17 @@

(define-macro (define-record-type name constructor pred . fields)
(let ([c-fields (cdr constructor)] [c (car constructor)])
(let ([f-hash (make-immutable-hash
(map (λ (filed)
(cons (first filed) (second filed)))
fields))])
`(RECORDz
,pred ,c ,@(map (λ (c-f) (hash-ref f-hash c-f)) c-fields)))))
(let* ([nf (map (λ (filed)
(cons (first filed) (cons (gensym) (second filed))))
fields)]
[f-hash (make-immutable-hash nf)])
`(begin
(RECORDz
,pred ,c ,@(map (λ (c-f) (car (hash-ref f-hash c-f))) c-fields))
,@(map (λ (nfe)
(let ([p (cdr nfe)])
`(define ,(cdr p) ,(car p)))) nf)
))))
(define-record-type error-object
(error-object message irritants)
error-object?
Expand Down
44 changes: 0 additions & 44 deletions z-test.rkt

This file was deleted.

0 comments on commit c98aa54

Please sign in to comment.