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.devel Subject: Re: [PATCH] Fix error messages involving internal definitions Date: Fri, 27 Jan 2012 09:26:50 -0500 Message-ID: <877h0dnrv9.fsf@netris.org> References: <87sjj1obca.fsf@netris.org> <87obtpgzcb.fsf@pobox.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1327674506 28181 80.91.229.12 (27 Jan 2012 14:28:26 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 27 Jan 2012 14:28:26 +0000 (UTC) Cc: guile-devel@gnu.org To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Jan 27 15:28:22 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rqmml-0002Gi-4K for guile-devel@m.gmane.org; Fri, 27 Jan 2012 15:28:15 +0100 Original-Received: from localhost ([::1]:50207 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rqmmk-0006RI-DP for guile-devel@m.gmane.org; Fri, 27 Jan 2012 09:28:14 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:37162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rqmmd-0006R0-4d for guile-devel@gnu.org; Fri, 27 Jan 2012 09:28:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RqmmW-0004O3-WB for guile-devel@gnu.org; Fri, 27 Jan 2012 09:28:06 -0500 Original-Received: from world.peace.net ([96.39.62.75]:44620) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqmmW-0004MR-Tc for guile-devel@gnu.org; Fri, 27 Jan 2012 09:28:00 -0500 Original-Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=yeeloong) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1RqmmH-00073z-1u; Fri, 27 Jan 2012 09:27:45 -0500 In-Reply-To: <87obtpgzcb.fsf@pobox.com> (Andy Wingo's message of "Fri, 27 Jan 2012 12:27:16 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 96.39.62.75 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:13710 Archived-At: Andy Wingo writes: >> Thirdly, "definition in expression context" is a confusing message for >> Scheme beginners, who are likely to make this mistake. > > The problem is that I'm not sure that the error message you suggest is > correct. You show: > >> (let ((x 1)) >> #f >> (define blah 3)) >> >> Currently, you get a message like this: >> >> unknown location: definition in expression context in subform blah of 3 >> >> With this patch, you get a message like this: >> >> /home/mhw/guile-modules/foo.scm:5:2: internal definition in a context where definitions are not allowed in form (define blah 3) > > And this is much better. But, it is not the right error message for a > form like: > > (if 1 > (define bar 2)) > > So, that's question 1: can we come up with some other message that's > more helpful while also being accurate? How about if we simply remove 'internal' from the error message? > "Definition in expression context" does have the advantage that it can > be searched for in the manual (if we put it there), or on the web. If > all things were equal, it would have the advantage of being shorter as > well. How about this? "definition in expression context, where definitions are not allowed," > Question 2 is about the implementation. I'm sure you winced as much as > I did at adding a seventh return value from syntax-type :) I was > reading though and noted in the comment above syntax-type that the "s" > return value already has the source information for the expression. So > a more minimal change like the attached patch yields the error message: > > /tmp/foo.scm:5:2: definition in expression context in form blah > > WDYT? I think I prefer the more minimal approach in that patch, but > either way is fine. I agree that it is painful to add another value, but personally I think it is very important to include the entire from to make the error message comprehensible, especially for Scheme beginners who are quite likely to make this mistake. > Feel free to commit whatever you think is best, here. Thanks! Mark