From: David Bakhash
Subject: finding variables/sizes
Date: 
Message-ID: <cxjhfwbpapp.fsf@engc.bu.edu>
hey,

in CL (specifically, in ACL) is it possible to find out ALL the
package variables?  How would I sort them, possibly in terms of size?

thanks,
dave
From: Rainer Joswig
Subject: Re: finding variables/sizes
Date: 
Message-ID: <joswig-0711982039590001@194.163.195.67>
In article <···············@engc.bu.edu>, David Bakhash <·····@bu.edu> wrote:

> hey,
> 
> in CL (specifically, in ACL) is it possible to find out ALL the
> package variables?  How would I sort them, possibly in terms of size?

See the LOOP macro:
http://www.harlequin.com/education/books/HyperSpec/Body/mac_loop.html

See: do-symbols, do-all-symbols, WITH-PACKAGE-ITERATOR

See: boundp, intern, find-symbol

or use something similar to this:

(defun list-symbols (type package)
  (let ((symbols nil))
    (do-external-symbols (symbol package)
      (case type
        (class (let ((class-object (find-class symbol nil)))
                 (when (and class-object
                            (not (typep class-object 'structure-class))
                            (not (typep class-object 'built-in-class)))
                   (push symbol symbols))))
        (function (when (and (fboundp symbol)
                             (not (macro-function symbol))
                             (not (typep (symbol-function symbol)
                                         'standard-generic-function)))
                    (push symbol symbols)))
        (generic-function (when (and (fboundp symbol)
                                     (typep (symbol-function symbol)
                                            'standard-generic-function))
                            (push symbol symbols)))
        (macro (when (macro-function symbol)
                 (push symbol symbols)))
        (variable (when (boundp symbol)
                    (push symbol symbols)))
        (structure (let ((class-object (find-class symbol nil)))
                     (when (and class-object (typep class-object
                                                    'structure-class))
                       (push symbol symbols))))
        (all (push symbol symbols))))
    (sort symbols #'string-lessp :key #'symbol-name)))


? (clim-env::list-symbols 'variable (find-package "URL"))
(URL:*DOWNCASE-URL-STRINGS* URL:*ESCAPE-SEARCH-URLS*
URL:*PATHNAME-APPLICATION-EXTENSIONS*
URL:*PATHNAME-AUDIO-EXTENSIONS* URL:*PATHNAME-HTML-EXTENSIONS*
URL:*PATHNAME-IMAGE-EXTENSIONS* URL:*PATHNAME-LISP-EXTENSIONS*
URL:*PATHNAME-TEXT-EXTENSIONS* URL:*PATHNAME-VIDEO-EXTENSIONS*
URL:*QUALIFY-UNQUALIFIED-DOMAIN-NAMES* URL:*URL-HOST-NAME-RESOLUTION*)

-- 
http://www.lavielle.com/~joswig