unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Taylan Kammer <taylan.kammer@gmail.com>
To: Tobias Geerinckx-Rice <me@tobias.gr>,
	Maxime Devos <maximedevos@telenet.be>
Cc: Sarah Morgensen <iskarian@mgsn.dev>,
	50349@debbugs.gnu.org, guix-patches@gnu.org
Subject: bug#50349: [PATCH] packages: Add 'define-package' syntax.
Date: Sat, 4 Sep 2021 16:29:49 +0200	[thread overview]
Message-ID: <95c92fc5-1fcf-b347-370e-d1943f22c2c3@gmail.com> (raw)
In-Reply-To: <87y28caazy.fsf@nckx>

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




  reply	other threads:[~2021-09-04 14:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <15d01b32313f5f2f291b120597719ae92bd26acd.1630639896.git.iskarian@mgsn.dev>
     [not found] ` <757b7543b931335c3725264edfbc79c012aa10fc.camel@telenet.be>
2021-09-04 10:09   ` bug#50349: [PATCH] packages: Add 'define-package' syntax Tobias Geerinckx-Rice via Bug reports for GNU Guix
2021-09-04 14:29     ` Taylan Kammer [this message]
2021-09-04 14:44       ` Tobias Geerinckx-Rice via Bug reports for GNU Guix
2021-09-04 17:23         ` Taylan Kammer
2021-09-04 18:53           ` Sarah Morgensen
2021-09-04 21:01             ` Taylan Kammer
2021-09-04 23:17   ` Sarah Morgensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=95c92fc5-1fcf-b347-370e-d1943f22c2c3@gmail.com \
    --to=taylan.kammer@gmail.com \
    --cc=50349@debbugs.gnu.org \
    --cc=guix-patches@gnu.org \
    --cc=iskarian@mgsn.dev \
    --cc=maximedevos@telenet.be \
    --cc=me@tobias.gr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).