summaryrefslogtreecommitdiff
path: root/defun-1.lisp
blob: 49680e69d6fff027ebdf3c62dee995c15b2d41eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
(export '(defmacro defun))


(%defmacro* defun (name lambda-list . body)
  (let ((lambda-sym (gensym)))
    `(%defun ,name ,lambda-sym
       (d-b ,lambda-list nil nil ,lambda-sym
         ,@body))))

(%defmacro* defmacro (name lambda-list . body)
  (let ((arg-sym (gensym))
        (lambda-sym (gensym))
        (whole-sym (gensym))
        (env-sym (gensym)))
    `(%defmacro ,name ,arg-sym
       (let ((,whole-sym (first ,arg-sym))
             (,lambda-sym (cdr (first ,arg-sym)))
             (,env-sym (second ,arg-sym)))
         (d-b ,lambda-list ,env-sym ,whole-sym ,lambda-sym
           ,@body)))))

(%defmacro* lambda (lambda-list . body)
  (let ((lambda-sym (gensym)))
    `(%lambda ,lambda-sym
       (d-b ,lambda-list nil nil ,lambda-sym
         ,@body))))

(defun funcall (function &rest arguments)
  (apply function arguments))