Issue #7639 has been updated by duerst (Martin Dürst).
Assignee set to matz (Yukihiro M.)
sawa (Tsuyoshi Sawada) wrote:
duerst:
(please call me Martin)
I agree that bad comments (too long, unrelated to what’s going on,…)
are bad, and we should not be too concerned with that. However, that is
not my main point.
My main point is that currently in Ruby, I can look at the end of a line
or at the start of the next line to know whether a statement/expression
continues on the next line. If we allow comment lines before lines
starting with a dot, this is no longer the case. I have to read past the
comment to find the next non-comment line to know whether the statement
is continued or not.
Currently, in 100%, I know that I don’t have to look past a comment to
check for a line starting with a dot. If we introduce this proposal,
there will still be about 99% of case where the statement does not
continue after the comment, and therefore most people may easily miss a
continuation after a comment. That’s the problem I see with this
proposal, and that problem does not go away even if all comments are
good ones.
Looking at your proposal again, it seems to me that you are saying that
this is an inconsistency for people who write the code. But I think it
is because we want it to be easy for people to read the code (without
having to look ahead past comments to check for continuations).
I have assigned this to Matz, because he has the most ability and
experience to jugde this kind of writability/readability issue.
Feature #7639: More freedom for location of comments
Author: sawa (Tsuyoshi Sawada)
Status: Open
Priority: Normal
Assignee: matz (Yukihiro M.)
Category: core
Target version: Next Major
When we chain methods with the period at the end of each line, we can
put comments in between the lines:
[1, 2, 3].
# First, we do blah blah
method1.
# Second, we do blah blah
method2.
=begin
Third, the following line
does this
and that ...
=end
method3
but when we have the period at the beginning of the line, putting
comments in similar positions returns an error:
[1, 2, 3]
# First, we do blah blah
.method1
# Second, we do blah blah
.method2
=begin
Third, the following line
does this
and that ...
=end
.method3
# => Error
It is confusing that putting comments between lines in a method chain is
sometimes allowed and sometimes not. I think it would be convenient if
comments are allowed in these positions even when the following line
starts with a period, and I request this as a feature. Currently, it
returns an error, which means that, if such syntax were allowed, there
would be no conflict with the existing syntax.
Furthermore, putting the period at the beginning of a line is suited for
method chains because the period will visually work as bullets, and it
makes more sense to have comments right before those lines.