From: Maxime Devos <maximedevos@telenet.be>
To: yarl baudig <yarl-baudig@mailoo.org>, guile-devel@gnu.org
Subject: Re: define-module, #:export and export
Date: Wed, 4 Jan 2023 18:28:03 +0100 [thread overview]
Message-ID: <7848ba66-4ab6-ba9f-c930-bb99ae2542e7@telenet.be> (raw)
In-Reply-To: <ea-mime-63b5970b-11a2-2bdbe28d@www.mailo.com>
[-- Attachment #1.1.1: Type: text/plain, Size: 2051 bytes --]
On 04-01-2023 16:11, yarl baudig wrote:
> Hello guile.
>
> I don't know if that's a bug. Anyway, I am confused about this so I ask. I came across this problem playing with guix source code. I will share different "tests" each test is a directory with nothing but the files I share.
> each time the command to try the test (inside it's directory) is `guile --no-auto-compile -L . main.scm`
> [...]
My (untested) hypothesis (*: things I'm unsure about)
If there is no #:export (...), then when
(define-operation (valid-path?)) is expanded, the identifier
'valid-path?' is free (*).
Hence, the following ...
> (syntax-rules (name ...)
> ((_ name) id) ...)))))
refers to the free identifier 'valid-path?'.
Conversely, if there is #:export, then the (syntax-rules (name ...) ...)
looks for the bound identifier 'valid-path?' (*).
Important: bound identifiers != free-identifier, even if they have the
same symbol! For (simple-format #t "~S\n" (operation-id valid-path?))
to work, the 'valid-path?' of that expression must be bound if the
syntax-rules looks for a bound identifier, and free if it looks for a
free identifier.
By adding a (export valid-path?) between the simple-format and the
(define-operation ...), the 'valid-path?' in (simple-format ...) becomes
a bound identifier (*).
Proposed solutions:
(a) Move the (export ...) after the (simple-format ...) instead
of in-between the define-operation and simple-format
(b) Or put the uses of define-operation and define-enumeration-type
in the same file.
(c) Or use (eq? (syntax->datum ...) ...) instead of the
'syntax-rules (...)', to ignore the lexical environment
and hence the bound/free distinction.
(This has consequences for users of 'main' that rename their
import of 'valid-path?' -- by this change, operation-id will
expect the unrenamed name, whereas in the original code (IIUC)
it would expect the renamed name.)
Greetings,
Maxime.
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 929 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
next prev parent reply other threads:[~2023-01-04 17:28 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 [this message]
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
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=7848ba66-4ab6-ba9f-c930-bb99ae2542e7@telenet.be \
--to=maximedevos@telenet.be \
--cc=guile-devel@gnu.org \
--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).