cl-cookbook icon indicating copy to clipboard operation
cl-cookbook copied to clipboard

Mention (recommend?) ASDF package-inferred-system

Open Ambrevar opened this issue 6 years ago • 4 comments

Package-inferred-system have multiple benefits over the older way:

  • No need to list the files to compile.
  • No need to list the dependencies, ASDF will figure them out from the package imports.

If someone wants to have a list of all dependencies actually used by the system, the following function can do:

(defun system-depends-on (system)
  "List SYSTEM dependencies, even if SYSTEM is an inferred system.
From: https://gitlab.common-lisp.net/asdf/asdf/issues/10#note_5018."
  (let (depends)
    (labels ((iter (openlist)
                   (if (null openlist) depends
                       ;; Is this a subsystem of SYSTEM?
                       (let ((find (search system (first openlist))))
                         (if (and find (zerop find))
                             (iter (append (asdf:system-depends-on (asdf:find-system (first openlist))) (rest openlist)))
                             ;; If not, it's a direct dependency: collect it.
                             (progn
                               (pushnew (first openlist) depends :test 'equalp)
                               (iter (rest openlist))))))))
      (iter (list system)))))

Ambrevar avatar Aug 27 '19 09:08 Ambrevar

Is it really a good idea to recommend this feature?

I mean, even though you save some typing with it, you lost some maintenance, since the dependencies become implicit.

Also how do you specify if a symbol should be exported or not?

sheepduke avatar Aug 27 '19 09:08 sheepduke

I believe you save maintenance, since you don't have to keep the list of dependencies in the .asd in sync with what you actually use in the defpackage.

Note that this has nothing to do with symbol export, which happens in defpackage, not in the .asd.

Ambrevar avatar Aug 27 '19 09:08 Ambrevar

To mention, sure, I just wouldn't recommend it until I use it myself.

vindarel avatar Aug 27 '19 10:08 vindarel

Note that this has nothing to do with symbol export, which happens in defpackage, not in the .asd.

Sorry, I understand now.

It is a way to write ASDF system file, and has nothing to do with Lisp packages.

sheepduke avatar Aug 27 '19 11:08 sheepduke