unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#38760: R7RS define-library form is not supported
@ 2019-12-27  8:44 Amirouche
  2020-01-12 19:33 ` Andy Wingo
  0 siblings, 1 reply; 2+ messages in thread
From: Amirouche @ 2019-12-27  8:44 UTC (permalink / raw)
  To: 38760

Using guile-2.9.7.

Here is the tests files:

```scheme
$ cat main.scm
(import (scheme base))
(import (mylib))


(func)
$ cat mylib.scm
(define-library (mylib)

   (export func)

   (import (scheme base))
   (import (scheme write))

   (begin

     (define (func)
       (display 42)(newline))))
```

When i run `main.scm` with the `--r7rs` switch I get:

```
$ guile --r7rs -L . main.scm
guile: warning: failed to install locale
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /tmp/guile/r7rs/main.scm
;;; compiling ./mylib.scm
;;; WARNING: compilation of ./mylib.scm failed:
;;; Syntax error:
;;; mylib.scm:10:4: definition in expression context, where definitions 
are not allowed, in form (define (func) (display 42) (newline))
;;; WARNING: compilation of /tmp/guile/r7rs/main.scm failed:
;;; Syntax error:
;;; mylib.scm:10:4: definition in expression context, where definitions 
are not allowed, in form (define (func) (display 42) (newline))
;;; compiling ./mylib.scm
;;; WARNING: compilation of ./mylib.scm failed:
;;; Syntax error:
;;; mylib.scm:10:4: definition in expression context, where definitions 
are not allowed, in form (define (func) (display 42) (newline))
ice-9/psyntax.scm:2800:12: In procedure syntax-violation:
Syntax error:
mylib.scm:10:4: definition in expression context, where definitions are 
not allowed, in form (define (func) (display 42) (newline))
```

Removing the define-library's begin does not help.

Replacing define-library with library does lead to another error:

```scheme
$ guile --r7rs -L . main.scm
guile: warning: failed to install locale
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /tmp/guile/r7rs/main.scm
;;; compiling ./mylib.scm
;;; mylib.scm:6:2: warning: possibly unbound variable `import'
;;; mylib.scm:6:2: warning: possibly unbound variable `scheme'
;;; mylib.scm:6:2: warning: possibly unbound variable `write'
;;; <unknown-location>: warning: possibly unbound variable `display'
;;; compiled 
/home/amirouche/.cache/guile/ccache/3.0-LE-8-4.1/tmp/guile/r7rs/mylib.scm.go
;;; WARNING: compilation of /tmp/guile/r7rs/main.scm failed:
;;; Unbound variable: import
Backtrace:
            3 (primitive-load "/tmp/guile/r7rs/main.scm")
In ice-9/eval.scm:
    187:27  2 (_ _)
    223:20  1 (proc #<directory (guile-user) 7fcabe1def00>)
In unknown file:
            0 (%resolve-variable (7 . func) #<directory (guile-user) ?>)

ERROR: In procedure %resolve-variable:
Unbound variable: func
```

It says unbound `import` variable.  Add (import (only (guile) import)) 
on top make it work:

```scheme
$ cat mylib.scm
(library (mylib)

   (export func)

   (import (only (guile) import))
   (import (scheme base))
   (import (scheme write))

   (begin
     (define (func)
       (display 42)(newline))))
$ guile --r7rs -L . main.scm
guile: warning: failed to install locale
42
```





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#38760: R7RS define-library form is not supported
  2019-12-27  8:44 bug#38760: R7RS define-library form is not supported Amirouche
@ 2020-01-12 19:33 ` Andy Wingo
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Wingo @ 2020-01-12 19:33 UTC (permalink / raw)
  To: Amirouche; +Cc: 38760-done

Thanks for the report; fixed!  Patches welcome if there are any bugs :)

Cheers,

Andy





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-12 19:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-27  8:44 bug#38760: R7RS define-library form is not supported Amirouche
2020-01-12 19:33 ` Andy Wingo

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).