1
votes

I'm new to the world of Lisp project structure and I tackled my first bigger project in Lisp. That's why I started with a project skeleton made by quickproject:make-project. After this, my first idea was to create a folder structure, but I didin't knew exactly how I want to do it so I just made a few files to split code into.

I put some of my code in a file called pixel.lisp, some in gameview.lisp and the main loop is in pixelworld.lisp.

My asd file looks like this:

;;;; pixelworld.asd

(asdf:defsystem #:pixelworld
  :description "Describe pixelworld here"
  :author "Your Name <[email protected]>"
  :license  "Specify license here"
  :version "0.0.1"
  :serial t
  :depends-on (:sdl2 :cl-opengl)
  :components ((:file "package")
           (:file "pixel")
           (:file "gameview")
           (:file "pixelworld")))

If I understood it correctly this file should tell quickproject how to compile my system when I ql:quickload it. And because :serial is t it should compile in sequence. If I compile and evaluate each file by hand from top to bottom this works without any problem, so there is no problem with the dependencies. But when I ql:quickload the project and go into the package with (in-package :pixelworld) I cant run the main function because the other expressions in my system are not evaluated. Is there something fundamental I do not understand about this, or is there another command I have to use with quicklisp to get what I want? Thanks in advance. :)

1
Your asd file looks fine, do you have (in-package :pixelworld) at the top of all your files? Which file is main defined in? - Travis Sunderland
It is possible that you define a function that is used in a macro, and then you use that macro in a following form (all in the same file). By evaluating each form individually, everything works fine. But the compiler has no access to the auxiliary function used by the macro at the time the code is expanded (it was not yet defined, only declared). So please pay attention to the warnings and errors during compilation, perhaps by calling (asdf:compile-system :pixelworld) or using :vervose t in your call to ql:quickload ; if you add the error messages to this question we may be able to help more - coredump
I agree with @TravisSunderland: chances are you are missing in-package forms. This will have the result that whatever *package* is at the point you say (load ...) or (compile-file ...), that's what it will be in the file being loaded/compiled. QL / ASDF will, I hope, rebind it to CL-USER to make things repeatable, but meaning that different things happen for you. - user5920214
Thanks a lot, adding (in-package :pixelworld) in every file did the trick. And thanks to @tfb I now know why. Does one of you by any chance also know what i have to do if I make subfolders and structer my code that way? Do I have to use modules or are those things something completly different? - Echon
@Echon: I think that's another question. I'd use modules if I was doing it. - user5920214

1 Answers

1
votes

Like Travis Sunderland and tfg mentioned in the comments, it is important to have (in-package :pixelworld) on top of every file. After the change it worked flawlessly.