ruricolist / vernacular

Module system for languages that compile to Common Lisp
MIT License
59 stars 3 forks source link

List all loaded modules #3

Closed phoe closed 5 years ago

phoe commented 5 years ago

How should I retrieve a list of all modules currently loaded into Vernacular? The best I have found is find-module that nonetheless requires a pathname to be specified.

phoe commented 5 years ago

I see that vernacular/importing::*claimed-module-names* contains a hash table containing names of all loaded modules along with their import paths. Is it possible to export this information in any way?

ruricolist commented 5 years ago

The idea with *claimed-module-names* is to prevent a module name from being accidentally re-defined; it wasn't intended as a catalog.

I'm not averse to the idea, but let me ask: what do you need a listing of modules for?

phoe commented 5 years ago

I would like to retrieve a list all exported symbols per file loaded by CL-YESQL for introspection purposes. For that, I figured that I'd need a list of modules, unless I also keep that list myself in my own code.

phoe commented 5 years ago
(defun loaded-modules-alist ()
  "Return an alist of (path . module-object) for all loaded modules."
  (loop for path being the hash-keys of *module-cells*
          using (hash-value cell)
        unless (eql never (module-cell.timestamp cell))
          collect (cons path (module-cell.module cell))))

What is never? I assume it is a slot, but I do not see with-slots being used here.

ruricolist commented 5 years ago

It's a constant, part of Overlord's implementation of timestamps. Basically the negative infinity of timestamps.

On Fri, Apr 5, 2019, 12:38 AM Michał Herda notifications@github.com wrote:

(defun loaded-modules-alist () "Return an alist of (path . module-object) for all loaded modules." (loop for path being the hash-keys of module-cells using (hash-value cell) unless (eql never (module-cell.timestamp cell)) collect (cons path (module-cell.module cell))))

What is never? I assume it is a slot, but I do not see with-slots being used here.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/ruricolist/vernacular/issues/3#issuecomment-480154487, or mute the thread https://github.com/notifications/unsubscribe-auth/AAXwKNV5XhQIAcN98Tl2W37YuCkf8TpVks5vduFtgaJpZM4cE6Pd .

ruricolist commented 5 years ago

Implemented in https://github.com/ruricolist/overlord/blob/master/stamp.lisp.