[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Scheme-reports] [wg2] in support of single-arity procedural syntax transformers
On 05/12/2011 03:39 AM, Andy Wingo wrote:
> Yes, I've said that, though it does seem a minor point. (A herring-tail
> wagging a dog?) Basically the deal is that in an expression like:
>
> 0: (+ 37
> 1: foo
> 2: bar
> 3: baz)
>
> where `bar' is unbound, you want to say "line 2 column 4: `bar' is
> unbound", rather than attributing the error to (say) line 0. I keep
> using Racket as the example here, because I think they do it very well,
> even highlighting the expression precisely in their editor.
'bar' is the car of a pair, so if you track the position of the
pair during expansion, then you can provide a line/column for the
unbound variable. Either enter the pair in a weak map, or (as Kawa
does) use a subclass PairWithPosition that extends Pair but adds
position information.
This solution works pretty well in Kawa, which has good column-level
diagnostics. There are some problems: You can't give a precise
position to a symbol in the cdr of a dotted pair - but that is a minor
problem since Scheme doesn't allow dotted pairs in non-quoted expressions.
You can't readily distinguish between the position of list vs the
position of the first car, but in practice that works out pretty well.
What Kawa doesn't support is start/end-ranges, which is what you'd like
for an IDE. I think ou could work out a decent approximation using
context, but I haven't tried to do so. Better would be to add the
end-positions
to the PairWithPosition; and you could also add extra information to
disambiguate the cases from the previous paragraph. I haven't tried
to work out the specifics.
--
--Per Bothner
per@x http://per.bothner.com/
_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports