diff options
author | Thomas Albers Raviola <thomas@thomaslabs.org> | 2025-01-06 01:07:36 +0100 |
---|---|---|
committer | Thomas Albers Raviola <thomas@thomaslabs.org> | 2025-01-06 01:07:36 +0100 |
commit | 13e6a0738c47608af15cfcbc88a7a451a1e53fd9 (patch) | |
tree | faf38ee758f99b68cba2caedda133bad159036ee /src/eval.lisp | |
parent | 5b518ad7205b3432d95ff2b3757e49914233d913 (diff) |
Diffstat (limited to 'src/eval.lisp')
-rw-r--r-- | src/eval.lisp | 20 |
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) |