Why forbid ! in whitespace-only line? Beni Cherniavsky-Paskin (02 May 2013 04:54 UTC)
Re: Why forbid ! in whitespace-only line? David A. Wheeler (02 May 2013 22:24 UTC)
Re: Why forbid ! in whitespace-only line? David Vanderson (03 May 2013 00:57 UTC)
Re: Why forbid ! in whitespace-only line? David A. Wheeler (04 May 2013 22:56 UTC)

Re: Why forbid ! in whitespace-only line? David A. Wheeler 02 May 2013 22:24 UTC

Beni Cherniavsky-Paskin <xxxxxx@users.sf.net> wrote:

(Quoting the current draft SRFI-110):
> """
> 1. If an end-of-line sequence immediately follows the indentation and the
> indentation length is nonzero:
>   a. If the indentation contains “!”, it is an error; an implementation
> SHOULD reject it.
> """

Then:
> Why error rather than allowing it as either ignored or terminating line?
> I can see how punting the question "is ! empty" simplifies the spec, but it
> may be a missed opportunity.
>
> Once you prefix a block with !, it seems to me there is no reason to
> additionally require a comment — "! ;" (or other workarounds) — to express
> ignored vertical whitespace.
> Isn't this the cleanest thing possible:
>
> define long-func(x)
>   let ((foo bar(x)))
>   ! do stuff
>   ! ...
>   !
>   ! more stuff
>   ! ...
>
> In any case, I didn't find this discussed in the rationale.

Good point.  You can blame me here :-).

First, a line with ONLY spaces and tabs is considered to be the same as a blank line.  The reason is straightforward: In many circumstances you can't see the difference, so treating "no character" lines and "tabs+spaces only" lines differently could lead to subtle, hard-to-understand bugs.

So... what would a line with ONLY "!" in it mean?  Originally it meant the same thing ("blank line"), because it was a line with only indent characters.  However, that interpretation seemed odd, because you *can* see a difference.  Basically *that* semantic was confusing, so I believe I proposed changing it to "illegal" and no one complained.

But you're right, we could interpret lines with only "!", space, and tab as "ignored lines" instead (or ignored only if their indents match).  From a code point of view, it'd be trivial if lines with at least one "!", and ONLY "!", space, and tab, were treated as "ignore this line"... then we could reuse how it handles line-comment-only lines.

Thoughts?  I think that would be an easy change.

--- David A. Wheeler