unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Andy Wingo <wingo@pobox.com>
Cc: guile-devel@gnu.org
Subject: Re: [PATCH] Fix error messages involving internal definitions
Date: Fri, 27 Jan 2012 09:26:50 -0500	[thread overview]
Message-ID: <877h0dnrv9.fsf@netris.org> (raw)
In-Reply-To: <87obtpgzcb.fsf@pobox.com> (Andy Wingo's message of "Fri, 27 Jan 2012 12:27:16 +0100")

Andy Wingo <wingo@pobox.com> 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



      reply	other threads:[~2012-01-27 14:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-27  7:26 [PATCH] Fix error messages involving internal definitions Mark H Weaver
2012-01-27  7:58 ` Mark H Weaver
2012-01-27 11:27 ` Andy Wingo
2012-01-27 14:26   ` Mark H Weaver [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877h0dnrv9.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=guile-devel@gnu.org \
    --cc=wingo@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).