GNU bug report logs - #21944
Error on ordering of define-record-type and define-public in a module is unhelpful - possible improvement?

Previous Next

Package: guile;

Reported by: Koz Ross <koz.ross <at> retro-freedom.nz>

Date: Tue, 17 Nov 2015 17:44:04 UTC

Severity: normal

Full log


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

From: Mark H Weaver <mhw <at> netris.org>
To: Andy Wingo <wingo <at> pobox.com>
Cc: ludo <at> gnu.org, Koz Ross <koz.ross <at> retro-freedom.nz>, 21944 <at> debbugs.gnu.org
Subject: Re: bug#21944: Error on ordering of define-record-type and
 define-public in a module is unhelpful - possible improvement?
Date: Mon, 27 Jun 2016 12:10:08 -0400
Andy Wingo <wingo <at> pobox.com> writes:

> On Sun 26 Jun 2016 23:06, Andy Wingo <wingo <at> pobox.com> writes:
>
>> On Tue 17 Nov 2015 09:27, Koz Ross <koz.ross <at> retro-freedom.nz> writes:
>>
>>> I have the following file, called foo.scm:
>>>
>>> (define-module (koz foo)
>>>  #:use-module (srfi srfi-9))
>>>
>>> (define-public (make-empty-bar)
>>>   (make-bar #f))
>>>
>>> (define-record-type <bar>
>>>   (make-bar open)
>>>   bar?
>>>   (open bar-open set-bar-open!))
>>
>>> Would it be possible for the error message in this case to be a bit
>>> more helpful? Even better, would it be possible to not make this an
>>> issue when compiling?
>>
>> It would be possible to make the scope of make-bar be the whole file.
>> In theory it should work I guess, given this news entry from 2.0.1:
>>
>>   ** `begin' expands macros in its body before other expressions
>
> Apparently the reason this doesn't work in Guile right now is that the
> compiler currently reads and compiles one Scheme expression at a time,
> then stitches them together on the Tree-IL level.  Incidentally,
> `primitive-load' works in the same way for the interpreter: it reads and
> eval's single expressions in a loop.  We could change this to have Guile
> read the whole file and pass it all to the expander at once, within a
> `begin'.  This has some user-visible changes though:
>
>   * if evaluating an expression throws an error, primitive-load doesn't
>     read the following expressions and so doesn't detect syntax errors;
>     try a file like this:
>
>     (error "what")
>     )
>
>     With the interpreter (primitive-load) you will get the "what" error,
>     not a syntax error.  (Yes the unclosed paren hurts my eyeballs but I
>     wanted to demonstrate a syntax error.  Here's a matching paren:
>     ")".)
>
>   * Procedural macros won't be able to use bindings defined previously
>     in the file unless they are eval-whenned.  Of course this already
>     breaks in the compiler, but it succeeds in the interpreter.

Another problem is that in several places, we assume that if a top-level
form calls 'set-current-module', the forms that follow in the file will
now be expanded within that new module.  This behavior is needed for
'define-module' to work properly, and it's also assumed in boot-9.scm,
psyntax-pp.scm, and maybe some other places.

      Mark




This bug report was last modified 8 years and 354 days ago.

Previous Next


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