[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Fix error messages involving internal definitions
From: |
Mark H Weaver |
Subject: |
Re: [PATCH] Fix error messages involving internal definitions |
Date: |
Fri, 27 Jan 2012 09:26:50 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) |
Andy Wingo <address@hidden> 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