Only use one variable to store the unification environment in MATCHING
Fri Jan 15 08:49:26 UTC 2010 pix@kepibu.org
* Only use one variable to store the unification environment in MATCHING
Because of the way MATCHING expands, and what UNIFY* returns, each
(setf #:env (unify* ...))
call will do one of two things: it will set #:env to NIL or it will set #:env to
an ENVIRONMENT structure.
If #:env is set to NIL--the same value it entered the (setf) with!--the COND
will continue on to the next clause.
If #:env is set to an ENVIRONMENT structure, none of the remaining (setf)
clauses will be evaluated.
Thus, because the variable will only ever be set to a non-nil value once, this
should be perfectly safe.
hunk ./match-block.lisp 195
- (match-clauses-env-vars (mapcar (lambda (mc)[_^M_][_$_]
- (declare (ignore mc))[_^M_][_$_]
- (gensym "UNIFICATION-ENV-")[_^M_][_$_]
- )[_^M_][_$_]
- match-clauses))[_^M_][_$_]
+ (env-var (gensym "UNIFICATION-ENV-"))[_^M_][_$_]
hunk ./match-block.lisp 199
- (let ,match-clauses-env-vars[_^M_][_$_]
- (declare (dynamic-extent ,@match-clauses-env-vars))[_^M_][_$_]
- (cond ,@(mapcar (lambda (match-clause match-clause-env-var)[_^M_][_$_]
+ (let (,env-var)[_^M_][_$_]
+ (declare (dynamic-extent ,env-var))[_^M_][_$_]
+ (cond ,@(mapcar (lambda (match-clause)[_^M_][_$_]
hunk ./match-block.lisp 203
- match-clause-env-var))[_^M_][_$_]
- match-clauses[_^M_][_$_]
- match-clauses-env-vars)[_^M_][_$_]
+ env-var))[_^M_][_$_]
+ match-clauses)[_^M_][_$_]