From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo 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 10:02:37 +0200 Message-ID: <874m8f9i02.fsf@pobox.com> References: <20151117212713.48944f57195a04fd0a6c5d86@retro-freedom.nz> <871t3jbqxj.fsf@pobox.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1467014608 25803 80.91.229.3 (27 Jun 2016 08:03:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 27 Jun 2016 08:03:28 +0000 (UTC) Cc: ludo@gnu.org, 21944@debbugs.gnu.org To: Koz Ross Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Mon Jun 27 10:03:18 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 1bHRVl-0002ir-Dr for guile-bugs@m.gmane.org; Mon, 27 Jun 2016 10:03:17 +0200 Original-Received: from localhost ([::1]:57080 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHRVk-0003nV-ON for guile-bugs@m.gmane.org; Mon, 27 Jun 2016 04:03:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39720) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHRVb-0003kw-4W for bug-guile@gnu.org; Mon, 27 Jun 2016 04:03:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHRVW-0002ce-Ra for bug-guile@gnu.org; Mon, 27 Jun 2016 04:03:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:45101) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHRVW-0002ca-Nn for bug-guile@gnu.org; Mon, 27 Jun 2016 04:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bHRVW-0008Hn-Cd for bug-guile@gnu.org; Mon, 27 Jun 2016 04:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andy Wingo Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Mon, 27 Jun 2016 08:03: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.146701456831829 (code B ref 21944); Mon, 27 Jun 2016 08:03:02 +0000 Original-Received: (at 21944) by debbugs.gnu.org; 27 Jun 2016 08:02:48 +0000 Original-Received: from localhost ([127.0.0.1]:57438 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bHRVH-0008HJ-Vx for submit@debbugs.gnu.org; Mon, 27 Jun 2016 04:02:48 -0400 Original-Received: from pb-sasl1.pobox.com ([64.147.108.66]:51671 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bHRVF-0008HA-Nw for 21944@debbugs.gnu.org; Mon, 27 Jun 2016 04:02:46 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl1.pobox.com (Postfix) with ESMTP id 55A0E204B5; Mon, 27 Jun 2016 04:02:45 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=XiiyRHQvNClhVoSu/RuYbn7fAlY=; b=ehOXfu L+zqHr47Tp2fydJIinHAimU2Dvmiv8cZZn+kT18e/XGtd/mnYEKfuOPlAA/Y3Cyx 75KapFi/aaHUGXxEp7+LuUAhC76KpMPqaQAQ/8luaolbA2/wDXnYAWSSs5SvZAj6 dCoGfNmIatgmaFY1qhO1DMuHXeH9ti9oaip4k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=omussl3hElY0+4uqH3XCBfF87WxXNrzs vj/s5LKwTojEtoEN5Cp5vWKK8yBcrnTm/3aaBxuwFaDTWG+0se3JP66FAx675fH9 F6r2F64hgpLl67dFQLqsVLii3SMUscAGYrFriNvR/wCAz2RxCnZSC/3mZX3AGoZM JNx0OTCe7cg= Original-Received: from pb-sasl1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-sasl1.pobox.com (Postfix) with ESMTP id 4E917204B3; Mon, 27 Jun 2016 04:02:45 -0400 (EDT) Original-Received: from clucks (unknown [88.160.190.192]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pb-sasl1.pobox.com (Postfix) with ESMTPSA id 69467204B2; Mon, 27 Jun 2016 04:02:44 -0400 (EDT) In-Reply-To: <871t3jbqxj.fsf@pobox.com> (Andy Wingo's message of "Sun, 26 Jun 2016 23:06:48 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-Pobox-Relay-ID: 879B6D40-3C3D-11E6-9A14-C1836462E9F6-02397024!pb-sasl1.pobox.com 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:8262 Archived-At: 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. Maybe now is a good time to do this though, in 2.2. Ludovic, Mark: thoughts? Andy