[plt-scheme] Student parsing problem

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Tue Jun 2 18:55:01 EDT 2009

I have had students run into the same problem with #; comments, that a
#; before whitespace or another comment could be forgotten.  I think
all of the s-expression-eating reader forms should have the "no
whitespace/comment" restriction in the student languages.

--Carl

On Tue, Jun 2, 2009 at 6:37 PM, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
>
> This is an interesting error, and as a beginner I ran into this myself
> (1984, probably february or march :-)
>
> I have not seen this kind of error since then, however. Before you invest
> time, let's see how many people have had students who stumbled over this.
>
> -- Matthias
>
> On Jun 2, 2009, at 5:36 PM, Jay McCarthy wrote:
>
>> Yes, that would work for Beginner. But for the syntax highlighter, I
>> don't think there's a nice way. My final sentence's "but" should only
>> apply to the right-hand side of the "and".
>>
>> I'd change Beginner to show ya'll, but from what I can tell it use
>> parameters to communicate the different syntax to the real C-reader.
>> So I'd need to muck with that and add a new parameter... very messy
>> and not sure its what the Powers That Be would prefer.
>>
>> Jay
>>
>> On Tue, Jun 2, 2009 at 3:33 PM, Carl Eastlund <carl.eastlund at gmail.com>
>> wrote:
>>>
>>> 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
>>
>> --
>> Jay McCarthy <jay at cs.byu.edu>
>> Assistant Professor / Brigham Young University
>> http://teammccarthy.org/jay
>>
>> "The glory of God is Intelligence" - D&C 93


Posted on the users mailing list.