[plt-scheme] Student parsing problem
On Jun 3, Felix Klock's PLT scheme proxy wrote:
> Eli-
>
> On Jun 3, 2009, at 12:04 PM, Eli Barzilay wrote:
>
> > On Jun 3, Felix Klock's PLT scheme proxy wrote:
> >>
> >> On Jun 3, 2009, at 11:40 AM, Eli Barzilay wrote:
> >>
> >>> ...
> >>> and it works with multiple expressions too:
> >>>
> >>> (define (foo x)
> >>> ;#;#;
> >>> (printf "foo\n")
> >>> (printf " x = ~s\n" x)
> >>> ...)
> >>
> >> I find the amount of time my brain needs to lex and parse this to be
> >> an argument *for* the rule I suggested (which disallows the #;#;
> >> pattern).
> >
> > Strange. All you need is to look at the single `;' that starts the
> > line and ignore it.
>
> Okay, if my email client had source code highlighting (as DrScheme
> does), I probably would have discarded the ";#;#;" as well and not
> thought twice about it.
I don't think that it's difficult even without highlighting. The
question is whether there's a simple set of rules that you use when
you read the line. In this case, if your line is made of just `#;'s
and `;'s, then all you need is to count `#;'s and stop at the first
`;', the count is the number of following expressions to ignore. It's
even simpler than a line with `#;('.
> The real problem for me is whether the "#;#;" pattern should be
> considered good practice. That is the core of what I was objecting
> to.
I don't see any big deal here -- `#;' ignores the next sexpr, and
`#;#;' ignores the next two sexprs. But that's still irrelevant to
the point of the thread. (As I wrote in the other reply, it's also
much less likely to write this by accident.)
> Sam has pointed out to me that my preferred form (wrapping the
> sexp's in a begin and using a single "#;") would not work for when
> he comments out multiple cond clauses via repeated "#;".
It doesn't work for any context that is not an expression. (In the
same way that '(begin ...) was bad back before `#;'.)
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!