Re: Naive DEFSYSTEM replacement

"joswig (as joswig at lisp dot de)" <[email protected]>
Newsgroups gmane.lisp.lispworks.general
Message-ID <[email protected]>
I don't think what was provided is a DEFSYSTEM at all. It doesn't define a system, since there is nothing which would be a SYSTEM data structure and there are no top level operations over that data structure.

DEFCLASS defines a class, DEFUN defines a function, DEFTYPE defines a type...

The macro actually creates code to directly execute a computed list of lispworks:compile-file-if-needed function calls.
Since there are no dependencies managed, it always executes all of them.

We can simply turn the macro into a function without loss of functionality.
So far there is no need and no advantage in generating code via a macro

(defun compile-and-load-files (components)
  (labels ((checkout (file list)
             "Recursively replace FILE with the items in LIST"
             (append (loop for req in 
                             (cddr (find file list 
                                         :test #'string= :key #'car)) 
                           append (checkout req list))
                     (list file)))

           (reorder (list)
             "Turn our dependency list inside out"
             (loop for (file nil . reqs) in list 
                   append (append (loop for sub in reqs 
                                        append (checkout sub list))
                                  (list file))))

           (inflate (c)
             "Turn each string into a sort of pathname"
             (if (keywordp (car c))
                 (let ((subdir (string-downcase 
                                (symbol-name (car c)))))
                   (mapcar (lambda (s)
                             (mapcar (lambda (c) 
                                       (concatenate 'string 
                                                    subdir "/" c))
                                     (append (list (first s))
                                             (cddr s))))
                           (cdr c)))
               (copy-list c)))

           (compile-it (file)
             (compile-file-if-needed file :load t)))

    (let ((hcl:*compiler-break-on-error* t))
      (mapcar #'compile-it
              (delete-duplicates (mapcan (lambda (c) 
                                           (reorder (print (inflate c))))
                                         components) 
                                 :test #'equal
                                 :from-end t))
      t)))



(defvar *riskmate-components*
  '((:cl-ppcre
     ("packages")
     ("specials"  :needs "packages"))

    (:chipz
     ("package")
     ("constants" :needs "package"))

    (:gray-streams
     ("package")
     ("streams"   :needs "package"))

    (:salza2
     ("package")
     ("reset"     :needs "package"))

    (("package")
     ("anzsic"    :needs "package" "init")
     ("asset"     :needs "package" "init")
     ("chrome"    :needs "package")
     ("claim"     :needs "package" "init" "document")
     ("client"    :needs "package" "init")
     ("contact"   :needs "package" "init")
     ("crypto"    :needs "package" "utils" "mime")
     ("fcgi"      :needs "package")
     ("document"  :needs "package" "init" "client"))))


(compile-and-load-files *riskmate-components*)


> Martin came closest, in pointing out an unconsidered flaw in my toy
> implementation - it doesn't handle automatic recompilation. 
> 
> But it's not a use-case I have, to be honest. When I redefine macros, I
> recompile the files that use them. I wouldn't have thought of invoking
> LW:COMPILE-SYSTEM again... which I should've thought of.

This was especially important in old times, when recompiling a system could take a long time.
I can remember full compilation times of Portable Common LOOPS (PCL), a portable CLOS implementation, on some machine taking half an hour. COMPILE-SYSTEM would then minimize the compilation time, by only compiling/loading necessary code into a running system. One would back then avoid restarting Lisp and avoid doing full compilations of large systems.
The idea of SYSTEMS was born when machines had 1 MIPS or less CPU speed.

> Am 26.07.2025 um 02:24 schrieb Adam Weaver (as adam at cleversure dot com dot au) <[email protected]>:
> 
> On Fri, 2025-07-25 at 05:50 -0400, Zach Beane wrote:
>>>  I want the files to be in alphabetical order
>> 
>> You have invented this requirement and it's the source of your pain.
> 
> 100% ! You're absolutely correct.
> 
> But I notice that none of the responses have actually answered the
> question I asked, which was *why* ASDF:DEFSYSTEM is as complicated as
> it is. 
> 
> Martin came closest, in pointing out an unconsidered flaw in my toy
> implementation - it doesn't handle automatic recompilation. 
> 
> But it's not a use-case I have, to be honest. When I redefine macros, I
> recompile the files that use them. I wouldn't have thought of invoking
> LW:COMPILE-SYSTEM again... which I should've thought of.
> 
> So yeah.
> 
> Seriously, can anyone answer *why* ASDF:DEFSYSTEM and MK:DEFSYSTEM
> are hundreds and thousands of lines of code when my toy 19-line 
> implementation does something approximate?
> 
> A
> 
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> [email protected]
> http://www.lispworks.com/support/lisp-hug.html


_______________________________________________
Lisp Hug - the mailing list for LispWorks users
[email protected]
http://www.lispworks.com/support/lisp-hug.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.