Lisp HUG Maillist Archive

Buglet in environment functions?

Hi

here is the example:

CL-USER 8 > (variable-information 'foo
                                  (augment-environment nil
                                                       :variable (list 'foo)
                                                       :declare '((type fixnum foo))))
:LEXICAL
T
NIL

At leaste SBCL and CCL return

((TYPE . FIXNUM))

as third value.  Which is what I expected.

All the best

--
Marco Antoniotti, Associate Professor tel. +39 - 02 64 48 79 01
DISCo, Università Milano Bicocca U14 2043 http://bimib.disco.unimib.it
Viale Sarca 336
I-20126 Milan (MI) ITALY

Please note that I am not checking my Spam-box anymore.
Please do not forward this email without asking me first.





Re: Buglet in environment functions?

Unable to parse email body. Email id is 12900

Re: Buglet in environment functions?

Hi!
  This might be useful in some cases (sometimes)

(defmacro let1 (variable + &body progn)
  "Shortcut for (let ((a b)) . c) or (destructuring-bind a b . c)"
  (if (atom variable)
      `(let ((,variable ,+)) ,@progn)
    `(destructuring-bind ,variable ,+ ,@progn)))

; and also iterate-keywords is used, but you can simply avoid that.

(defun variable-type-or-class (VAR ENV)
  "Returns type of a class of var in env"
  #+:LISPWORKS4.4
  (cond
   ((constantp VAR ENV)
    (class-of var))
   (ENV
    (let1 remote-environment (slot-value env 'lexical::remote-environment)
      (when remote-environment
        (let1 variable-types
            (iter (:for venv in (slot-value remote-environment 'compiler::venv))
              (ignored (struct-to-alist venv))
              (:collect `(,(slot-value venv 'compiler::name)
                          ,(slot-value venv 'type))))
          (cadr (assoc var variable-types))))
      )))
  #+lispworks6
  (cond
   ((constantp var env)
    (class-of var))
   (env
    (let1 venvs (slot-value env 'compiler::venv)
      (when venvs
        (let1 variable-types
            (iter (:for venv in venvs)
              (ignored (struct-to-alist venv))
              (:collect `(,(slot-value venv 'compiler::name)
                          ,(slot-value venv 'type))))
          (cadr (assoc var variable-types))))))
   );cond
  #-(or :LISPWORKS4.4 :lispworks6)
  (when (constantp var env) (class-of var)))

Sometimes it is known to work. Might be wrong in general case though.
Use at your risk.

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Updated at: 2020-12-10 08:34 UTC