🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

5 total messages Started by Anton Antimo Tue, 01 Dec 2026 14:31
usage of in-package and defsystem
#106
Author: Anton Antimo
Date: Tue, 01 Dec 2026 14:31
27 lines
1591 bytes
I see serious packages doing things like this:

(in-package :cl-user)

(defpackage :cl-gd.system
  (:use :cl :asdf)
  (:export :*cl-gd-directory*))

(in-package :cl-gd.system)

(defparameter *cl-gd-directory*
  (make-pathname :name nil :type nil :version nil
                 :defaults (parse-namestring *load-truename*)))

(defsystem :cl-gd
  :version "0.6.1"
  :serial t
  :description "Interface to the GD graphics library"
  [...])

Why should I 

  (in-package :cl-user)

before defining my own package?

And why should I define my own package to define my system?
Re: usage of in-package and defsystem
#107
Author: tfb
Date: Tue, 01 Dec 2026 17:22
24 lines
1800 bytes
Anton Antimo <anton@safunu.org> wrote:

> 
> Why should I 
> 
>   (in-package :cl-user)
> 
> before defining my own package?

When a file is loaded the package is initially whatever its ambient value
was. Making it be CL-USER removes that uncertainty (to be more paranoid you
might want to say (cl:in-package :cl-user)).

> 
> And why should I define my own package to define my system?
> 

I generally define systems in ASDF-USER.  But in the case you give it's not
just systems being defined: it's other things as well: you likely want
those in their own package, not some shared playground.


-- 
tfeb.org/computer/
Re: usage of in-package and defsystem
#108
Author: Madhu
Date: Tue, 01 Dec 2026 18:04
39 lines
2466 bytes
* tfb <11emvo4$1uu33$1@dont-email.me> :
Wrote on Tue, 1 Dec 2026 17:22:12 -0000 (UTC):
> Anton Antimo <anton@safunu.org> wrote:
>
>>
>> Why should I
>>
>>   (in-package :cl-user)
>>
>> before defining my own package?
>
> When a file is loaded the package is initially whatever its ambient value
> was. Making it be CL-USER removes that uncertainty (to be more paranoid you
> might want to say (cl:in-package :cl-user)).

And so that the following defpackage form can be just be defpackage
instead of needing to be cl:defpackage.

evaluate-last-sexp in sly/slime searches backwards for an in-package
form (at column 0) and evaluates the expression in that package. So an
in-package cl-user at the top is a good idea for this.


>> And why should I define my own package to define my system?
>
>
> I generally define systems in ASDF-USER.  But in the case you give it's not
> just systems being defined: it's other things as well: you likely want
> those in their own package, not some shared playground.

In this case the the code uses the configuration variable
cl-gd.system:*cl-gd-directory* which gets defined when loading the asd
file.

Personally I don't like the idea of defining configuration variables in
the system definition file.  I'd just define that variable in a
config.lisp file that is loaded included in the system definition file
(.asd or .system)
Re: usage of in-package and defsystem
#109
Author: tfb
Date: Tue, 01 Dec 2026 19:02
15 lines
1653 bytes
Madhu <enometh@meer.net> wrote:
>
> Personally I don't like the idea of defining configuration variables in
> the system definition file.  I'd just define that variable in a
> config.lisp file that is loaded included in the system definition file
> (.asd or .system)
> 

I think ASDF encourages you to keep other things in the .asd file minimal. 
It's also good style, I agree.



-- 
tfeb.org/computer/
Re: usage of in-package and defsystem
#110
Author: Anton Antimo
Date: Wed, 02 Dec 2026 02:52
14 lines
1686 bytes
tfb <tfb@work.it.out> writes:

> Madhu <enometh@meer.net> wrote:
>>
>> Personally I don't like the idea of defining configuration variables in
>> the system definition file.  I'd just define that variable in a
>> config.lisp file that is loaded included in the system definition file
>> (.asd or .system)
>> 
>
> I think ASDF encourages you to keep other things in the .asd file minimal. 
> It's also good style, I agree.

Thank you two so much for the clear info.  Order is back in the house.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads