Skip to content
Browse files

Added expansion of macros to MODF-EXPAND.

  • Loading branch information...
1 parent bc762c3 commit 612253043afdd48fba7b5894873194cef5ed9bd1 @kisp kisp committed Aug 1, 2011
Showing with 9 additions and 6 deletions.
  1. +9 −6 modf.lisp
15 modf.lisp
@@ -277,14 +277,17 @@ functions ahead of time."
new-instance ))
;; <<>>=
-(defun modf-expand (new-val expr enclosed-obj-sym)
+(defun modf-expand (new-val expr enclosed-obj-sym env)
(cond ((or (atom expr) (eql (car expr) 'modf-eval))
`(let ((,enclosed-obj-sym ,expr))
,new-val ))
+ ((macro-function (car expr) env)
+ (modf-expand new-val (funcall (macro-function (car expr) env) expr env)
+ enclosed-obj-sym env))
;; First, try rewrite rules
((gethash (car expr) *modf-rewrites*)
(modf-expand new-val (funcall (gethash (car expr) *modf-rewrites*) expr)
- enclosed-obj-sym ))
+ enclosed-obj-sym env))
;; Okay, we are going to call modf-expand
(t (let* ((obj-sym (gensym))
(new-val (if enclosed-obj-sym
@@ -328,10 +331,10 @@ functions ahead of time."
(container-arg-n expr)
expr obj-sym ))))))
(nth (container-arg-n expr) expr)
- obj-sym )))))
+ obj-sym env)))))
;; <<>>=
-(defmacro modf (place value &rest more)
+(defmacro modf (place value &rest more &environment env)
"Make a new object \(which may use some of the old object) such that PLACE
evaluates to VALUE.
@@ -345,9 +348,9 @@ used in the subsequence MODF-PLACE NEW-VALUE pairs until the end of the MODF
(if more
(destructuring-bind (next-symbol next-place next-value &rest next-more) more
- `(let ((,next-symbol ,(modf-expand value place nil)))
+ `(let ((,next-symbol ,(modf-expand value place nil env)))
(modf ,next-place ,next-value ,@next-more) ))
- (modf-expand value place nil) ))
+ (modf-expand value place nil env) ))
(defun find-container (place)
(cond ((atom place)

0 comments on commit 6122530

Please sign in to comment.
Something went wrong with that request. Please try again.