[CM] asdf and clm on sbcl

Tito Latini tito.01beta at gmail.com
Thu Feb 16 03:23:35 PST 2017


On Thu, Feb 16, 2017 at 12:02:34AM +0100, Ralf Mattes wrote:
> [...]
> > but it avoids an error with (load "clm.asd"). i
> 
>  But that's exactly how you should not use an asdf file.
>  Loading the file will unconditionally execute the code in that file
>  while (asdf:load-system ...) will not, once the system is loaded. That
>  makes quite a difference, esp. when asdf files contain substantial
>  amounts of code (CM, hintm hint ;-)

`(load "clm.asd")' is a simple registration of the wrapper to all.lisp:

  (APPLY 'ASDF/PARSE-DEFSYSTEM:REGISTER-SYSTEM-DEFINITION '"clm"
         '(:DESCRIPTION "Common Lisp Music" :VERSION "5" :AUTHOR ...))

therefore, if some scripts used LOAD with the old asd file, they
continue to work after the recent changes (probably only with asdf-3).

CLM is a fantastic tool without lisp-dependences and it works with a
simple ROCK-AND-ROLL function:

sh> mkdir /path/to/clm-5/build

;; ~/.sbclrc
(export 'rock-and-roll "CL-USER")

(defvar clm-bin-directory "/path/to/clm-5/build/")

(defun cl-user:rock-and-roll ()
  (unless (find-package "CLM")         
    (load "/path/to/clm-5/all.lisp")
    (provide "CLM"))
  (setf *package* (find-package "CLM")))

(pushnew (lambda (name)
           (when (string-equal (string name) "clm")
             (cl-user:rock-and-roll)))
         *module-provider-functions*)


sh> sbcl
(member :asdf *features*)  ; => NIL
(rock-and-roll)            ; with conditional compilation!
;; or the alternative `(require :clm)'

# A quiet garage (no sputtering)
sh> ls /path/to/clm-5/build
audio.o           defaults.fasl  headers.o     run.fasl
clm-package.fasl  defins.fasl    initmus.fasl  sndlib2clm.fasl
clm.o             env.fasl       io.o          sndplay
clm1.fasl         export.fasl    libclm.so     sound.fasl
cmus.o            ffi.fasl       mus.fasl      sound.o


> I wouldn't advise to use sbcl's current extension to require to load
> asdf systems. You're relying on the order of sb-impl::*module-provider-functions*
> (but I have to confess that 'require does give cozzy nostalgic feelings
> ...)

I like REQUIRE, that's not a nostalgic utility, it works with or
without the optional asdf and SB-EXT:*MODULE-PROVIDER-FUNCTIONS* is
not an internal symbol.

sh> sbcl
*module-provider-functions*
;; => (SB-IMPL::MODULE-PROVIDE-CONTRIB)

(require :asdf)
*module-provider-functions*
;; => (ASDF/OPERATE:MODULE-PROVIDE-ASDF SB-IMPL::MODULE-PROVIDE-CONTRIB)

where ASDF/OPERATE:MODULE-PROVIDE-ASDF uses ASDF/OPERATE:REQUIRE-SYSTEM,
a version of ASDF/OPERATE:LOAD-SYSTEM that skips trying to update
systems that are already loaded.


More information about the Cmdist mailing list