Started work on nlambda. It isn't working yet.
This commit is contained in:
parent
0550b0168f
commit
facd5ccc94
8 changed files with 118 additions and 22 deletions
27
lisp/defun.lisp
Normal file
27
lisp/defun.lisp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
;; Because I don't (yet) have syntax for varargs, the body must be passed
|
||||
;; to defun as a list of sexprs.
|
||||
(set! defun!
|
||||
(nlambda
|
||||
(name args body)
|
||||
(cond (symbolp name)
|
||||
(set! name (apply lambda (cons args body))))))
|
||||
|
||||
(defun! square (x) ((* x x)))
|
||||
|
||||
(set! defsp!
|
||||
(nlambda
|
||||
(name args body)
|
||||
(cond (symbolp name)
|
||||
(set! name (nlambda args body)))))
|
||||
|
||||
(defsp! cube (x) ((* x x x)))
|
||||
|
||||
(set! p 5)
|
||||
|
||||
(square 5) ;; should work
|
||||
|
||||
(square p) ;; should work
|
||||
|
||||
(cube 5) ;; should work
|
||||
|
||||
(cube p) ;; should fail: unbound symbol
|
||||
Loading…
Add table
Add a link
Reference in a new issue