[r6rs-discuss] [Formal] #;<datum> comments useless

From: Per Bothner <per>
Date: Sat Sep 30 00:06:40 2006

Trent Buck wrote:
> On Mon, Sep 18, 2006 at 04:29:43PM +0000, Per Bothner wrote:
>> One-sentence summary of the issue: #;<datum> comments useless
>
> ;([^\n]*)\n is always equivalent to #|\1|#. It saves two characters.

Three, since you want a newline once in a while anyway.

> Block comments are strictly more powerful than line comments, because
> one can comment out not just a single line but as many as you want.
>
> By these arguments, both #; and ; should be removed (leaving only
> #||#).

Line comments have their uses for short comments describing an
expression or variable. Besides they're historical, and removing
them is not an option.

>> In "production" code or anything else supposed to be maintainable
>> you clearly should use #|...|# instead since it is much safer and
>> clearer exactly what is commented out.
>
> That sounds like opinion. If it's objective truth, can you please
> prove it?

Of course it's my opinion, informed by taste and experience. But it
seems fairly clear that you can accidentally comment out the wrong
thing more easily with #:... than with #|...|# and (more important)
the compiler won't help you find your mistake. If you misplace the
|# the the reader will complain. With #; you have to know where
the s-expr ends, and if you're wrong it is still a valid s-expr.

> Firstly, when the comment expression is the last subexpression, it
> does not break up the trailing parens with the closing lexeme. Of the
> following two forms, I consider the former more aesthetically pleasing
> than the latter.
>
> (+
> (- foo
> bar
> #;
> (this is
> a
> long
> (expression (that
> has
> many
> parens)))))
>
>
> (+
> (- foo
> bar
> #|
> (this is
> a
> long
> (expression (that
> has
> many
> parens)))|#))

Aa I said above: you really don't want this in production code, or more
generally anything that is 'checked in" (to a source-code repository).
What is the purpose? If you want to comment out a fragment of
production code you need to explain *why* it is commented out,
using *text* - and so it's no longer an s-expr.

Furthermore, it seldom makes sense to comment out an s-expr, especially
in a functional (or mostly-functional) language. You comment out a
parameter to a function, and the function suddenly has the wrong arity.
It only makes sense for side-effecting actions whose values are ignored,
or rare parameters to variable-arity functions.

> Secondly, because #; guarantees to comment out exactly one expression,
> I do not need to look for the closing lexeme. In the above example,
> it would be quite easy for a student to accidentally write
>
> (+
> (- foo
> bar
> #|
> (this is
> a
> long
> (expression (that
> has
> many
> parens))|#)))
>
> producing a syntactic error that is potentially very difficult to
> detect (without a smart editor).

But since you should always use a smart editor, this point is moot.
It is also moot because the example is not an illustration of
something anyone would want to do - it's a contrived example
without motivation.

> Thirdly, it is safe for an editor to assume that the expression
> commented out by #; is a symbolic expression, rather than arbitrary
> text. This means it can safely provide the same indenting and
> structured editing facilities that it provides outside of comments.
> For example, if the buffer contains
>
> #;-!- A
>
> then typing ( could usefully insert both opening and closing
> parentheses:
>
> #;(-!-) A
>
> And if the buffer contains
>
> #;(foo bar-!- baz)
>
> then typing Return could usefully indent after adding a newline:
>
> #;(foo bar
> -!-baz)
>
> In the above examples, -!- indicates the position of the cursor.

But without any meaningful examples showing the use of s-expr comments
in real code it seems the feature should go away for lack of usefulness.

I.e. the proponents of #; need to illustrate how using #; is better
that #|...|# in real code, or at least during development (debugging).
I have seen no such examples.
-- 
	--Per Bothner
per_at_bothner.com   http://per.bothner.com/
Received on Sat Sep 30 2006 - 00:06:08 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC