On 04.09.2021 12:09, Tobias Geerinckx-Rice via Bug reports for GNU Guix wrote: > All, > > To keep a link with previous ‘define-package’ discussion, I've merged this > bug with #15284. It was never resolved IMO and things have changed since > 2013 with the label-less input style. > > Maxime Devos 写道: >> This could be even shorter in the special case that the variable name >> and package name are the same (modulo types): >> >> (define-package "my-favorite-package" >> (version ...) >> ...) > > (define-anything STRING ...) is just too weird to ack. Are there any package > names that aren't currently valid symbols? Is there a good reason for them? > > Kind regards, > > T G-R
To me the most obvious thing to do seems (define-package foo ...) ;no explicit name needed to bind the variable 'foo' and use symbol->string for the name of the package, with the possibility to override the name like (define-package foo (name "foobar") ...) which would bind the variable 'foo' to a package named "foobar". Here's a syntax-case definition: (define-syntax define-package (lambda (stx) (syntax-case stx () ((_ <name> (<field> <value> ...) ...) (if (memq 'name (map syntax->datum #'(<field> ...))) #'(define-public <name> (package (<field> <value> ...) ...)) #`(define-public <name> (package (name #,(symbol->string (syntax->datum #'<name>))) (<field> <value> ...) ...))))))) -- Taylan