[Openmcl-devel] accessing lexical variables (lexical-environment vs definition-environment)

Marco Baringer mb at bese.it
Tue Jul 19 07:34:02 PDT 2005


i need a function which, at macro expansion time, collects the names
(as symbols) of all the visibile lexical variables. is there anything
which looks blatently wrong with this?

(defun lexical-variables (environment)
  (loop
     for env = environment
          then (ccl::lexenv.parent-env env)
     while (and env
                (not (ccl::istruct-typep env 'ccl::definition-environment)))
     for vars = (ccl::lexenv.variables env)
     when (listp vars)
     append (mapcar (lambda (var)
                      ;; ccl::var-name is a macro, se we can't do #'ccl::var-name directly
                      (ccl::var-name var))
                    vars)))  

in particular i want to make sure that i can stop looking for
variables as soon as i hit a definition-environment object.

tia.

-- 
-Marco
Ring the bells that still can ring.
Forget the perfect offering.
There is a crack in everything.
That's how the light gets in.
	-Leonard Cohen




More information about the Openmcl-devel mailing list