GNU bug report logs - #52218
Unable to define more than one R7RS library per file

Previous Next

Package: guile;

Reported by: Sam Lee <samlee746 <at> yahoo.com>

Date: Wed, 1 Dec 2021 08:56:01 UTC

Severity: normal

Full log


Message #8 received at 52218 <at> debbugs.gnu.org (full text, mbox):

From: Linus Björnstam <linus.bjornstam <at> veryfast.biz>
To: "Sam Lee" <samlee746 <at> yahoo.com>, 52218 <at> debbugs.gnu.org
Subject: Re: bug#52218: Unable to define more than one R7RS library per file
Date: Wed, 01 Dec 2021 11:00:46 +0100
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




This bug report was last modified 3 years and 255 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.