![](https://secure.gravatar.com/avatar/f8a16f607621c6b2820dcfff6fc22507.jpg?s=120&d=mm&r=g)
Thanks everyone for the help, but as the noob here perhaps it is of interest to the experts to see how I saw the situation, and what might help. When I write a form like: (defun main () (write-line "urg")) and the loader error diagnostic is "The variable MAIN is unbound" without any evidence in the backtrace of what is going on, my intuition from 40 years of programming in 23+ languages does not leap to ah, missing "use :cl". If here the error message had complained about either "defun" or "write-line", I would have gone huh, seem to be missing some fundamental stuff, try adding ":use :cl". If it was C or C++ say, the analogy might be: void myfunc() { printf("urg\n"); } and the linker not complaining about printf, but rather myfunc not being defined, when I somehow neglected to link against libc. That's a quite a misdirection... and it did cause me to spend (cough) some time before I broke down and disturbed this list. Finally I'll note that the only examples I've seen, and I actually did suck down the repo for lisp-interface-library, *do not show :use :cl*. For instance have a look at the code snippets from the ASDF.pdf manual on page 26. There are two there, and neither has a use :cl or :common-lisp or whatever. To fix this is trivial. Add in a :use :cl in those code snippets, and perhaps add "be sure to add :use :cl if you :use any other systems" in the docs for uiop:define-package. Finally I am extremely heartened that I didn't get dumped on here, I appreciate it a lot and I am extremely excited to get down to work building stuff in CL. All the best, Russell ps: I have waded through many of the colossal build systems out in the wild, and I know what I want when I'm setting up a project. ASDF looks just *fine* compared to cmake, for instance. That's why I'm so deep in the weeds so soon. On 1/9/25 4:38 AM, Faré wrote:
My memories are dim, but I believe it's a case of absence of :use argument being the same as (:use :common-lisp) but if you have an explicit :use argument, you need to explicitly include :common-lisp in the list for it to be included.
—♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org “The only saving grace of government is that they’re incompetent, because if they could do what they really want, it would be horrible for all of us”
On Thu, Jan 9, 2025 at 6:58 AM Robert Dodier <robert.dodier@gmail.com> wrote:
For the record, I can reproduce the behavior noted in the comments -- (asdf:load-system "hello") succeeds if (:use :alexandria) is omitted, and fails with "Variable MAIN is unbound" otherwise. I am working with SBCL.
It appears that the .lisp was successfully compiled, and the error occurs when trying to load the resulting .fasl.
After some tinkering, I think the problem is that the symbols DEFUN and WRITE-LINE aren't being resolved to symbols in the symbol package COMMON-LISP. I can get the example to work, with (:use :alexandria), by either writing cl:defun and cl:write-line in the code, or saying (:use :common-lisp) in the package definition.
I don't know offhand why the symbols aren't resolved in the presence of (:use :alexandria), no doubt there's a simple explanation.
Hope this helps,
Robert
On Wed, Jan 8, 2025 at 3:58 PM Robert Goldman <rpgoldman@sift.info> wrote:
Will you please post a backtrace from SBCL for this. I'm not at all sure I understand what you mean by "this line fails."
What did you do to trigger the error?
(asdf:load-system "hello")
?
On 8 Jan 2025, at 17:37, Russell L. Carter wrote:
Greetings,
I am a common-lisp noob. I am not a programmer noob, nor a build system noob.
I have carefully studied fare's asdf manual, pages 25-26 in the pdf and backwards through the reverse dependencies of the terms used, about the package-inferred-system. I have a problem that I've whittled down to a very small snippet.
I'm using SBCL 2.4.10.117-507e7ae05 and its native ASDF, but also tested against ASDF repo head (ln -s into ~/common-lisp, verified in the repl).
My question is why this system, located in file "./hello.asd", containing:
________________________________
(asdf:defsystem "hello" :class :package-inferred-system :depends-on ("hello/src/main"))
________________________________
paired with the system/package file "./src/main.lisp", containing:
________________________________
(uiop:define-package :hello/src/main ;; (:use :alexandria) ;; XXXRLC This line fails: "The variable MAIN ;; is unbound". I have no idea why. Backtrace provides no clues ;; (to me). Load the library in the repl matters not. Elide that ;; line and (asdf:load-system "hello") => T and then CL-USER> ;; (hello/src/main:main) => urg \n "urg" as expected. (:export #:main))
(in-package :hello/src/main) (defun main () (write-line "urg"))
________________________________
fails as described in the comment. Sure I would like the answer but the more interesting question is how could I debug this failure?
I slogged through the late '90s debugging complex C++ template programming errors. Pages and pages of output. I don't mind doing it again. But I don't know where to start with this ASDF build system.
Thank you for any suggestions, obviously the answer must be trivial.
All the best, Russell L. Carter
Robert P. Goldman Research Fellow Smart Information Flow Technologies (d/b/a SIFT, LLC)
319 N. First Ave., Suite 400 Minneapolis, MN 55401
Google Voice: (612) 326-3934 Cell: (612) 384-3454 Email: rpgoldman@SIFT.net