guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: unknown location: definition in expression context in subform optnam


From: Mark H Weaver
Subject: Re: unknown location: definition in expression context in subform optname-from of "_^"
Date: Thu, 26 Jan 2012 21:26:48 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

Bruce Korb <address@hidden> writes:

> On 01/26/12 16:10, Mark H Weaver wrote:
>>>>>>    unknown location: definition in expression context in subform 
>>>>>> optname-from
>>>>> of "_^"
>>
>> The other interesting thing here is that the error message above says
>> "_^" instead of the full string "A-Z_^".  That suggests that the string
>> literal was not properly read.
>>
>> Bruce, are you sure that the following expression was passed directly to
>> 'eval' or 'primitive-eval'?
>
> I am completely certain.  Unfortunately, though the string now looks like 
> this:
>
> (define opt-name       "")
> (define extra-ct       0)
> (define extra-text     "")
> (define optname-from   "A-Z_^")
> (define optname-to     "a-z--")
> (make-tmp-dir)
>
> (if (exist? "preserve-case") (begin
>   (set! optname-from "_^")
>   (set! optname-to   "--") ))
>
> Upon careful examination of the entire, not-clipped string,
> I know at one point those "set!" used to be "define".
> Then I got bit, went through several fixup cycles and an old version
> must have been copied into place.  Sorry for the bother.

Okay, in that case, this all makes perfect sense.  The error was
actually referring to the (define optname-name "_^") that was within the
'if', and indeed that would be a non-top-level definition within
expression context and thus illegal.

>> PS: As a side note to the Guile developers: the error message here is
>>      misleading, because in the call to 'syntax-violation' within the
>>      'define*' cases of 'expand-expr', the bound identifier is passed as
>>      the 'subform' and the bound value is passed as the 'form'.
>>      Unfortunately, there is no way to fix this without changing the
>>      values that 'syntax-type' returns for 'define*' forms.
>
> Too bad.  I do prefer clue-ful error messages and "unknown location"
> just wasn't the helpful clue I needed.  Perhaps just use "improper location"?
> "invalid location"?  Just not "unknown location".

That part of the error message (where "unknown location" was printed)
would normally contain the filename, line number, and column number.
In this case, Guile did not have source location information for that
expression because it came from a C string.  That's why it wrote
"unknown location".

> It sounds like Guile is out in the weeds and cannot really tell me
> what's awry.

The message "definition in expression context" accurately conveys the
nature of the error, though I agree that it is rather terse and likely
to confuse Scheme beginners.  Perhaps we should rephrase it.

However, the 'in subform optname-from of "_^"' portion is definitely not
correct, and it would be good to fix that.  It would have been far more
helpful if it printed the entire definition form.  I'll look into it.

    Thanks,
      Mark



reply via email to

[Prev in Thread] Current Thread [Next in Thread]