aboutsummaryrefslogtreecommitdiff
path: root/src/eval.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval.lisp')
-rw-r--r--src/eval.lisp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/eval.lisp b/src/eval.lisp
index b2c399c..bc1d1c8 100644
--- a/src/eval.lisp
+++ b/src/eval.lisp
@@ -25,27 +25,29 @@
"Link is not callable: ~A" link)
(first link))
+(defun bind-arguments (environment lambda-list arguments specialp)
+ (unless specialp
+ (map-into arguments (curry #'eval-tree environment) arguments))
+ (append (mapcar #'cons lambda-list arguments)
+ environment))
+
(defun eval-chain (environment chain siblings)
"Evaluate CHAIN inside ENVIRONMENT and possibly consume SIBLINGS. Returns a
link with the evaluated body of the function under the ENVIRONMENT"
(destructuring-bind (head &rest arguments)
(chain-links chain)
(with-accessors ((function closure-function)
- (type closure-type)
+ (special closure-special-p)
+ (lambda-list closure-lambda-list)
(group-predicate closure-group-p))
;; Evaluate all elements of first link and get closure object
(link-closure (eval-tree environment head))
(multiple-value-bind (consumed-siblings rest)
(group-if group-predicate siblings)
(values
- (apply function
- environment
- consumed-siblings
- (ecase type
- (:special
- arguments)
- (:function
- (mapcar (curry #'eval-tree environment) arguments))))
+ (funcall function
+ (bind-arguments environment lambda-list arguments special)
+ consumed-siblings)
rest)))))
(defun eval-tree (environment node)