* bug#52218: Unable to define more than one R7RS library per file [not found] <20211201074553.bzuoffwpaxw3da44.ref@localhost> @ 2021-12-01 7:45 ` Sam Lee via Bug reports for GUILE, GNU's Ubiquitous Extension Language 2021-12-01 10:00 ` Linus Björnstam 0 siblings, 1 reply; 4+ messages in thread From: Sam Lee via Bug reports for GUILE, GNU's Ubiquitous Extension Language @ 2021-12-01 7:45 UTC (permalink / raw) To: 52218 Guile is unable to handle more than one define-library per file. For example, this is "mylibs.sld", which contains two define-library: (define-library (example mylib) (import (scheme base)) (export f) (begin (define (f x) (+ x 1)))) (define-library (example main) (import (scheme base) (scheme write) (example mylib)) (export main) (begin (define (main) (display "The answer is: ") (display (f 1)) (newline)))) When loading this file into Guile using "guile -l mylibs.sld", or by using (load "mylibs.sld"), Guile will show this error: ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /home/user/mylibs.sld ;;; WARNING: compilation of /home/user/mylibs.sld failed: ;;; Syntax error: ;;; unknown location: definition in expression context, where definitions are not allowed, in form (define (main) (display "The answer is: ") (display (f 1)) (newline)) ice-9/psyntax.scm:2794:12: In procedure syntax-violation: Syntax error: /home/user/mylibs.sld:14:4: definition in expression context, where definitions are not allowed, in form (define (main) (display "The answer is: ") (display (f 1)) (newline)) The error is always caused by the second define-library. Apparently, Guile no longer understands that define-library is a special form by the time the second define-library is evaluated. Is it not possible to define two R7RS libraries in the same file? Guile version: 3.0.7 ^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#52218: Unable to define more than one R7RS library per file 2021-12-01 7:45 ` bug#52218: Unable to define more than one R7RS library per file Sam Lee via Bug reports for GUILE, GNU's Ubiquitous Extension Language @ 2021-12-01 10:00 ` Linus Björnstam 2021-12-02 2:55 ` Sam Lee via Bug reports for GUILE, GNU's Ubiquitous Extension Language 0 siblings, 1 reply; 4+ messages in thread From: Linus Björnstam @ 2021-12-01 10:00 UTC (permalink / raw) To: Sam Lee, 52218 Hi Sam! I am not a maintainer , nor a very proficient guile hacker, but I do have some input. This is in line with the limitations of guile's R6RS implementation. I think this is a long standing, low priority bug. It has to do with the expansion of library (or define-library in this case) not properly resetting the current module. In the manual there is a section called "R6RS incompatibilities" that mentions this. Maybe an "R7RS incompatibilities" should be added. Best regards Linus Björnstam On Wed, 1 Dec 2021, at 08:45, Sam Lee via Bug reports for GUILE, GNU's Ubiquitous Extension Language wrote: > Guile is unable to handle more than one define-library per file. For > example, this is "mylibs.sld", which contains two define-library: > > (define-library (example mylib) > (import (scheme base)) > (export f) > (begin > (define (f x) > (+ x 1)))) > > (define-library (example main) > (import (scheme base) > (scheme write) > (example mylib)) > (export main) > (begin > (define (main) > (display "The answer is: ") > (display (f 1)) > (newline)))) > > > When loading this file into Guile using "guile -l mylibs.sld", or by > using (load "mylibs.sld"), Guile will show this error: > > ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 > ;;; or pass the --no-auto-compile argument to disable. > ;;; compiling /home/user/mylibs.sld > ;;; WARNING: compilation of /home/user/mylibs.sld failed: > ;;; Syntax error: > ;;; unknown location: definition in expression context, where > definitions are not allowed, in form (define (main) (display "The > answer is: ") (display (f 1)) (newline)) > ice-9/psyntax.scm:2794:12: In procedure syntax-violation: > Syntax error: > /home/user/mylibs.sld:14:4: definition in expression context, where > definitions are not allowed, in form (define (main) (display "The > answer is: ") (display (f 1)) (newline)) > > > The error is always caused by the second define-library. Apparently, > Guile no longer understands that define-library is a special form by the > time the second define-library is evaluated. Is it not possible to > define two R7RS libraries in the same file? > > Guile version: 3.0.7 ^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#52218: Unable to define more than one R7RS library per file 2021-12-01 10:00 ` Linus Björnstam @ 2021-12-02 2:55 ` Sam Lee via Bug reports for GUILE, GNU's Ubiquitous Extension Language 2021-12-03 14:20 ` Linus Björnstam 0 siblings, 1 reply; 4+ messages in thread From: Sam Lee via Bug reports for GUILE, GNU's Ubiquitous Extension Language @ 2021-12-02 2:55 UTC (permalink / raw) To: Linus Björnstam; +Cc: 52218 On 2021-12-01 11:00 +0100, Linus Björnstam wrote: > This is in line with the limitations of guile's R6RS implementation. I > think this is a long standing, low priority bug. It has to do with the > expansion of library (or define-library in this case) not properly > resetting the current module. > > In the manual there is a section called "R6RS incompatibilities" that > mentions this. Maybe an "R7RS incompatibilities" should be added. Hi Linus, There already exist a page in the manual about "Incompatibilities with the R7RS" [1]. Perhaps a paragraph similar to that found in the R6RS incompatibilities page should be added to the R7RS incompatibilities page. Something like this: "Multiple @code{define-library} forms in one file are not yet supported. This is because the expansion of @code{define-library} sets the current module, but does not restore it. This is a bug." [1]: https://www.gnu.org/software/guile/manual/html_node/R7RS-Incompatibilities.html ^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#52218: Unable to define more than one R7RS library per file 2021-12-02 2:55 ` Sam Lee via Bug reports for GUILE, GNU's Ubiquitous Extension Language @ 2021-12-03 14:20 ` Linus Björnstam 0 siblings, 0 replies; 4+ messages in thread From: Linus Björnstam @ 2021-12-03 14:20 UTC (permalink / raw) To: Sam Lee; +Cc: 52218 It is the same bug. The r7rs define-library expands to a r6rs library, which expands to a guile module form that lacks support for multiple libraries. The solution would probably include a non-trivial (but probably not very big) change to guile's module system. First you would have to save and restore the current module before and after a module definition (maybe in save-module-excursion?). Then I would separate the library form the guile library form (since that doesn't encapsulate the body), by expanding it directly to the lower level module forms. I might give it a shot. -- Linus Björnstam On Thu, 2 Dec 2021, at 03:55, Sam Lee wrote: > On 2021-12-01 11:00 +0100, Linus Björnstam wrote: >> This is in line with the limitations of guile's R6RS implementation. I >> think this is a long standing, low priority bug. It has to do with the >> expansion of library (or define-library in this case) not properly >> resetting the current module. >> >> In the manual there is a section called "R6RS incompatibilities" that >> mentions this. Maybe an "R7RS incompatibilities" should be added. > > Hi Linus, > > There already exist a page in the manual about "Incompatibilities with > the R7RS" [1]. Perhaps a paragraph similar to that found in the R6RS > incompatibilities page should be added to the R7RS incompatibilities > page. Something like this: > > "Multiple @code{define-library} forms in one file are not yet supported. > This is because the expansion of @code{define-library} sets the current > module, but does not restore it. This is a bug." > > [1]: > https://www.gnu.org/software/guile/manual/html_node/R7RS-Incompatibilities.html ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-03 14:20 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20211201074553.bzuoffwpaxw3da44.ref@localhost> 2021-12-01 7:45 ` bug#52218: Unable to define more than one R7RS library per file Sam Lee via Bug reports for GUILE, GNU's Ubiquitous Extension Language 2021-12-01 10:00 ` Linus Björnstam 2021-12-02 2:55 ` Sam Lee via Bug reports for GUILE, GNU's Ubiquitous Extension Language 2021-12-03 14:20 ` Linus Björnstam
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).