unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Jean Abou Samra <jean@abou-samra.fr>
To: yarl baudig <yarl-baudig@mailoo.org>,
	Maxime Devos <maximedevos@telenet.be>,
	guile-devel@gnu.org
Subject: Re: define-module, #:export and export
Date: Sun, 8 Jan 2023 16:23:30 +0100	[thread overview]
Message-ID: <a745157a-dc30-6123-0766-688f9257ebf8@abou-samra.fr> (raw)
In-Reply-To: <ea-mime-63badec9-2073-14a09a42@www.mailo.com>


[-- Attachment #1.1: Type: text/plain, Size: 1249 bytes --]

Le 08/01/2023 à 16:18, yarl baudig a écrit :
> Obviously...
>
> Ok, I tried more.
> Apparently,
>
> (define-syntax define-enumerate-type
>    (syntax-rules ()
>      ((_ name->int (name id) ...)
>       (define-syntax name->int
>         (syntax-rules (name ...)
> 	 ((_ name) id) ...)))))
>
> works the same as
>
> (define-syntax define-enumerate-type
>    (syntax-rules ()
>      ((_ name->int (name id) ...)
>       (define-syntax name->int
>         (lambda (x)
> 	 (syntax-case x ()
> 	   ((_ n) (free-identifier=? #'name #'n) #'id) ...))))))
>
> . Now what about
>
> (define-syntax define-enumerate-type
>    (syntax-rules ()
>      ((_ name->int (name id) ...)
>       (define-syntax name->int
>         (lambda (x)
> 	 (syntax-case x ()
> 	   ((_ n) (equal?
> 		   (syntax->datum #'name)
> 		   (syntax->datum #'n))
> 	    #'id) ...))))))
>
> ?



Yes, that was Maxime's suggestion (c). It essentially means you take the 
symbol
value of the argument to the macro without caring about whether it is bound
or renamed.

If you're doing this, maybe it's simpler to just turn the macro into a 
function
that accepts symbol values and call it as (my-enum 'foo) instead of 
(my-enum foo)?




[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

  reply	other threads:[~2023-01-08 15:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-04 15:11 define-module, #:export and export yarl baudig
2023-01-04 17:28 ` Maxime Devos
2023-01-05  2:07   ` Jean Abou Samra
2023-01-06 13:31     ` yarl baudig
2023-01-06 13:55       ` Maxime Devos
2023-01-07 16:24         ` Jean Abou Samra
2023-01-08  9:46           ` yarl baudig
2023-01-08 13:19             ` Jean Abou Samra
2023-01-08 15:18               ` yarl baudig
2023-01-08 15:23                 ` Jean Abou Samra [this message]
2023-01-13  7:58                   ` yarl baudig

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://www.gnu.org/software/guile/

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

  git send-email \
    --in-reply-to=a745157a-dc30-6123-0766-688f9257ebf8@abou-samra.fr \
    --to=jean@abou-samra.fr \
    --cc=guile-devel@gnu.org \
    --cc=maximedevos@telenet.be \
    --cc=yarl-baudig@mailoo.org \
    /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.
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).