[plt-scheme] Student parsing problem

From: Eli Barzilay (eli at barzilay.org)
Date: Wed Jun 3 13:52:19 EDT 2009

On Jun  3, Anthony Cowley wrote:
> On Wed, Jun 3, 2009 at 1:14 PM, Eli Barzilay<eli at barzilay.org> wrote:
> > On Jun  3, John Clements wrote:
> >>
> >> On Jun 3, 2009, at 8:40 AM, Eli Barzilay wrote:
> >> > and it works with multiple expressions too:
> >> >
> >> >  (define (foo x)
> >> >    ;#;#;
> >> >    (printf "foo\n")
> >> >    (printf "  x = ~s\n" x)
> >> >    ...)
> >>
> >> This is the most frightening idea I've heard today.
> >
> > I *seriously* don't see what would be frightening about it.
> FWIW, I reflexively looked away from the screen in horror when I saw
> that, too. In my case, at least, it's not simply the leading
> semicolon, but an unfamiliarity with using #; in such a manner. My
> reaction to the ;#;#; combination is a wooks-ian aversion to opaque
> notation whose far-reaching semantics are not immediately obvious,
> "Oh, this is a commented out notation that, if uncommented, would
> comment out the next two (count 'em!) S-expressions!"

There are two concepts here: the use of `;' as a line comment, which
is nothing new, and stacking `#;'s, which seems to be more, uh,
"radical" -- to my surprise.  So, ignoring `;' for now, what I'm
saying is that stacking `#;' makes sense if you look at it in this

1. We want a convenient way to comment the next sexpr, even when not
   in an expression position.

2. Solution: `#;' does that.

3. Just like it's convenient to comment out the next *single* sexpr,
   it can be convenient to comment out the next two sexprs.

4. A point of objection might be the ability to `#;' each of the two.
   A counter point to this is the convenience of uncommenting a single
   construct -- in exactly the same way that `#;' is more convenient
   than `#|...|#'.

5. Now, if you do agree that there's a utility in commenting out two
   expressions, what would be a convenient syntax for that?
   - `#2;' means that you'll also need to add `#1;'
   - `#;;' is ambiguous with using `;' as a line comment
   - `##;' doesn't follow the normal convention of `#' as a dispatch
   - `#;#;' works, and doesn't require any change to readers that
     support `#;'.  Problem solved.

6. And here is my surprise: I think that the last item is natural, and
   works well in the "spirit of scheme" of a minimal solution that
   generalizes elegantly.  So my conclusion is that what people find
   intimidating is the need for a syntax to "comment the next two
   sexprs" -- and that surprises me: why would "comment the next
   sexpr" be less radical than "comment the next two sexprs"?

> My real aversion was to the stacking of the #;, commenting them out is
> just the kicker. I'm now going to mentally prepare myself for the day
> when I come across code with #;#;#;;#;;#; in front of some
> vertically-long expressions.

When you parse the meaning of this line in the same way you did above,
then you get to a way to control how many expressions in the tail are
being ignored -- and this seems to be way less useful as a concept,
since you'd probably want those control points to be close to the
expressions that get disabled.

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

Posted on the users mailing list.