[plt-scheme] Student parsing problem

From: Eli Barzilay (eli at barzilay.org)
Date: Wed Jun 3 14:30:09 EDT 2009

On Jun  3, John Clements wrote:
> I think the basic fear arises from the fact that #; textually breaks
> the tree structure of the language.  Put differently, imagine that
> (zap) is an expression which comments out the following expression.
> What would
> (zap) (zap) (my-long-sexp ...) (my-next-long-sexp)
> mean?  Would the first zap zap the zap, or would it instead zap the
> second sexpression?

But since it's at the reader level, then the first (zap) wouldn't even
see the second one, and the zapped expression.  In any case, my
conclusion from this is that people find the way the reader works
confusing (at least this is my best guess at what was so difficult
about it).

On Jun  3, Anthony Cowley wrote:
> My opinion is that #; as a way to comment out an expression is
> justifiable because it's easier to toggle than #| |# *and* it is
> syntactically adjacent to the expression it affects (this is a
> not-so-subtle callback to the origins of this thread).
> I agree that it is convenient to comment out multiple sexprs, but I
> think that, at this point, one falls back to the #| |# syntax

Well, that still has the same problem of two points that needs editing
if you want to uncomment the two expressions back in.  (BTW, just the
word "uncomment" is a strong hint that this kind of convenience is

> because the alternatives, from which you make a strong case for the
> one you've chosen, require a more complicated mental parse. It's not
> a binary toggle ("I'm in a commented out region now") and the syntax
> in front of me might not indicate that it is commented out. It's
> adding an unusual stack component to the parsing that requires more
> than one bit of state to understand.

One thing that I will agree with is that this is not a good thing to
do when the expressions are longer than a few lines.  Certainly,
scrolling back your code just to count the number of `#;'s at the top
would be absolutely horrible.

> Your derivation of the form is appreciated and does make sense, so
> it is certainly understandable, it just doesn't feel like Scheme
> (trees and lists) to me, but that's subjective.

Yes, it's a subjective point -- and one that applies to just plain
`#;' too.  For example:

  ' #; (a b c) (x y z)

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.