[plt-scheme] Student parsing problem

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Tue Jun 2 17:33:23 EDT 2009

On Tue, Jun 2, 2009 at 5:27 PM, Jay McCarthy <jay.mccarthy at gmail.com> wrote:
> I just helped a student debug their program. It looked like this:
>
> (define (function1 arg)
>  ...
>  )
> `;;(html (body "Text"))
>
> (define (function2 arg)
>  ...)
>
> (function2 1)
>
> Naturally it is easy to tell that the problem is that ` finds the next
> s-expression, even if there are comments and whitespace between it and
> the next one; so function2 isn't really defined at all.
>
> Now, it seems reasonable for this to be a problem that the user should
> deal with in the Module and other higher languages. But you can get
> the same problem in Beginner (w/ List Abbrevs):
>
> (define (foo bar)
>  1)
> `;; Example
>
> (define (zog zag)
>  2)
>
> (zog 1)
>
> It would be nice, IMHO, if Beginner restricted ` and ' to be adjacent
> and the standard syntax Scheme highlighter in other languages made
> quoted expression visually distinct, but it doesn't appear that that
> is easy to do without trying to do a full parse, plus there is the
> obvious macro problem.
>
> Jay

This sounds like a custom reader problem to me, which avoids all
issues of parsing in the editor and "macro problems".  "Just" make it
a read error to have whitespace, comments, etc. between ` or ' and
their subsequent, implicitly-wrapped s-expression.

--Carl


Posted on the users mailing list.