Skip to content

Commit

Permalink
Allow irrefutable patterns in arguments to define (Issue #127)
Browse files Browse the repository at this point in the history
  • Loading branch information
eholk committed Feb 25, 2014
1 parent bef90f6 commit 9347aa6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion harlan/front/expand-macros.scm
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
x*)
env)))
`(lambda ,(reify x* env) . ,(reify b* env))))))
((define)
((prim-define)
(match x
((,define (,name ,x* ...) ,b* ...)
(let ((env^ (cons (cons name (ident-symbol name))
Expand Down
16 changes: 16 additions & 0 deletions lib/harlan/core.kfc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@
(extern open_outfile (str) -> (ptr ofstream))
(extern str->vec (str) -> (vec char))
(extern time-s () -> float)

(define-macro define-binders ()
((_ name ((tag x ...) binder ...) (arg ...) (e ...))
(define-binders name (binder ...)
(arg ... match-tmp)
((match match-tmp
((tag x ...)
(begin e ...))))))
((_ name (x binder ...) (arg ...) (e ...))
(define-binders name (binder ...) (arg ... x) (e ...)))
((_ name () (arg ...) (e ...))
(prim-define (name arg ...) e ...)))

(define-macro define ()
((_ (name binder ...) e ...)
(define-binders name (binder ...) () (e ...))))

(define-macro cond (else)
((_ (else body))
Expand Down

0 comments on commit 9347aa6

Please sign in to comment.