[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: define-module, #:export and export
From: |
Maxime Devos |
Subject: |
Re: define-module, #:export and export |
Date: |
Wed, 4 Jan 2023 18:28:03 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 |
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.
OpenPGP_0x49E3EE22191725EE.asc
Description: OpenPGP public key
OpenPGP_signature
Description: OpenPGP digital signature
- define-module, #:export and export, yarl baudig, 2023/01/04
- Re: define-module, #:export and export,
Maxime Devos <=
- Re: define-module, #:export and export, Jean Abou Samra, 2023/01/04
- Re: define-module, #:export and export, yarl baudig, 2023/01/06
- Re: define-module, #:export and export, Maxime Devos, 2023/01/06
- Re: define-module, #:export and export, Jean Abou Samra, 2023/01/07
- Re: define-module, #:export and export, yarl baudig, 2023/01/08
- Re: define-module, #:export and export, Jean Abou Samra, 2023/01/08
- Re: define-module, #:export and export, yarl baudig, 2023/01/08
- Re: define-module, #:export and export, Jean Abou Samra, 2023/01/08
- Re: define-module, #:export and export, yarl baudig, 2023/01/13