unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Jean Abou Samra <jean@abou-samra.fr>
To: Zelphir Kaltstahl <zelphirkaltstahl@posteo.de>,
	Guile User <guile-user@gnu.org>
Subject: Re: Guile import issue
Date: Thu, 15 Jun 2023 12:29:30 +0200	[thread overview]
Message-ID: <955482b76ca8ddddcbd661ef7b606990bd503128.camel@abou-samra.fr> (raw)
In-Reply-To: <4e120d8e-f399-caff-8ce3-c432d8213730@posteo.de>

[-- Attachment #1: Type: text/plain, Size: 2003 bytes --]

I agree, it seems like a bug.

Here is a slightly more minimal example:

```
$ cat rectangular.scm 
(library (rectangular)
  (export real-part)
  (import (guile))
  (define real-part car))

$ cat solution.scm 
(use-modules ((rectangular) #:prefix rect:))
(display (rect:real-part '(1 . 2)))

$ guile3.0 --fresh-auto-compile -L . solution.scm 
[...]
ERROR: In procedure real-part:
In procedure real-part: Wrong type argument in position 1: (1 . 2)
```

On the other hand, this doesn't happen if you replace rectangular.scm with


```
(define-module (rectangular)
  #:export (real-part))
(define real-part car)
```

I think the implementation of the R6RS library form is to blame here: look at this.

```
scheme@(guile-user)> ,expand (library (rectangular) (export real-part) (import (guile)) (define real-part car))
$1 = (begin
  (let ((m ((@@ (guile) define-module*)
            '(rectangular)
            #:filename
            #f
            #:pure
            #t
            #:version
            '()
            #:declarative?
            #t)))
    ((@@ (guile) set-current-module) m)
    m)
  (let ((iface ((@@ (guile) resolve-r6rs-interface) '(guile))))
    ((@@ (guile) call-with-deferred-observers)
     (lambda ()
       ((@@ (guile) module-use-interfaces!)
        ((@@ (guile) current-module))
        ((@@ (guile) list) iface)))))
  (if #f #f)
  ((@@ (guile) call-with-deferred-observers)
   (lambda ()
     ((@@ (guile) module-export!)
      ((@@ (guile) current-module))
      '())))
  ((@@ (guile) call-with-deferred-observers)
   (lambda ()
     ((@@ (guile) module-re-export!)
      ((@@ (guile) current-module))
      '(real-part))))
  ((@@ (guile) call-with-deferred-observers)
   (lambda ()
     ((@@ (guile) module-replace!)
      ((@@ (guile) current-module))
      '())))
  (define real-part car))
```

As you can see, the library macro has turned the (export real-part) part into a re-export from (guile).

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  parent reply	other threads:[~2023-06-15 10:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-14 20:15 Guile import issue Zelphir Kaltstahl
2023-06-15  9:59 ` Unstable Horse via General Guile related discussions
2023-06-15 12:27   ` Zelphir Kaltstahl
2023-06-15 10:29 ` Jean Abou Samra [this message]
2023-06-15 10:33   ` Jean Abou Samra
2023-06-15 12:25     ` Zelphir Kaltstahl

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=955482b76ca8ddddcbd661ef7b606990bd503128.camel@abou-samra.fr \
    --to=jean@abou-samra.fr \
    --cc=guile-user@gnu.org \
    --cc=zelphirkaltstahl@posteo.de \
    /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).