From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.bugs Subject: 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 Message-ID: <87eg7ia9zz.fsf@netris.org> References: <20151117212713.48944f57195a04fd0a6c5d86@retro-freedom.nz> <871t3jbqxj.fsf@pobox.com> <874m8f9i02.fsf@pobox.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1467043956 13981 80.91.229.3 (27 Jun 2016 16:12:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 27 Jun 2016 16:12:36 +0000 (UTC) Cc: ludo@gnu.org, Koz Ross , 21944@debbugs.gnu.org To: Andy Wingo Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Mon Jun 27 18:12:24 2016 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bHZ96-0002uf-2N for guile-bugs@m.gmane.org; Mon, 27 Jun 2016 18:12:24 +0200 Original-Received: from localhost ([::1]:59771 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHZ95-0000DZ-Co for guile-bugs@m.gmane.org; Mon, 27 Jun 2016 12:12:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHZ7q-0006hw-2B for bug-guile@gnu.org; Mon, 27 Jun 2016 12:11:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHZ7m-0007Cq-Qc for bug-guile@gnu.org; Mon, 27 Jun 2016 12:11:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:46099) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHZ7m-0007Cd-N5 for bug-guile@gnu.org; Mon, 27 Jun 2016 12:11:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bHZ7m-0008JZ-EJ for bug-guile@gnu.org; Mon, 27 Jun 2016 12:11:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Mon, 27 Jun 2016 16:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21944 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 21944-submit@debbugs.gnu.org id=B21944.146704383231917 (code B ref 21944); Mon, 27 Jun 2016 16:11:02 +0000 Original-Received: (at 21944) by debbugs.gnu.org; 27 Jun 2016 16:10:32 +0000 Original-Received: from localhost ([127.0.0.1]:58436 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bHZ7H-0008Ii-My for submit@debbugs.gnu.org; Mon, 27 Jun 2016 12:10:31 -0400 Original-Received: from world.peace.net ([50.252.239.5]:34675) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bHZ7E-0008IP-US for 21944@debbugs.gnu.org; Mon, 27 Jun 2016 12:10:29 -0400 Original-Received: from pool-71-174-35-80.bstnma.east.verizon.net ([71.174.35.80] helo=jojen) by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1bHZ78-0003IM-KX; Mon, 27 Jun 2016 12:10:22 -0400 In-Reply-To: <874m8f9i02.fsf@pobox.com> (Andy Wingo's message of "Mon, 27 Jun 2016 10:02:37 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.95 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.org gmane.lisp.guile.bugs:8266 Archived-At: Andy Wingo writes: > On Sun 26 Jun 2016 23:06, Andy Wingo writes: > >> On Tue 17 Nov 2015 09:27, Koz Ross 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 >>> (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