[ruby-dev:46830] [ruby-trunk - Feature #7639] More freedom for location of comments

From: duerst (Martin Dürst) <duerst@...>
Date: 2013-01-03 09:35:23 UTC
List: ruby-dev #46830
Issue #7639 has been updated by duerst (Martin D端rst).


I think I disagree. The fact that comments before lines starting with a dot are currently disallowed may be an artefact of how it was implemented (or it may have been intended from the start). But in the end, I think it is a feature. Usually, people check the end of a line to find out whether the statement continues on the next line. For lines starting with a dot, they have to check the start of the *next* line. If we allow comments between these lines, there is no limit for how far one has to check to find out whether the statement is over or continues. The next line starting with a dot could be a hundred lines away or a thousand or more lines away. That's why I think it's a good idea to not allow comments before lines starting with a dot.
----------------------------------------
Feature #7639: More freedom for location of comments
https://bugs.ruby-lang.org/issues/7639#change-35194

Author: sawa (Tsuyoshi Sawada)
Status: Open
Priority: Normal
Assignee: 
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.


-- 
http://bugs.ruby-lang.org/

In This Thread