https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112012-12-31T16:07:44ZRuby Issue Tracking SystemRuby master - Feature #7639: More freedom for location of commentshttps://bugs.ruby-lang.org/issues/7639?journal_id=351672012-12-31T16:07:44Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Category</strong> set to <i>core</i></li><li><strong>Target version</strong> set to <i>3.0</i></li></ul> Ruby master - Feature #7639: More freedom for location of commentshttps://bugs.ruby-lang.org/issues/7639?journal_id=351942013-01-03T18:35:18Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<ul></ul><p>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 <em>next</em> 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.</p> Ruby master - Feature #7639: More freedom for location of commentshttps://bugs.ruby-lang.org/issues/7639?journal_id=355762013-01-24T17:51:02Zsawa (Tsuyoshi Sawada)
<ul></ul><p>duerst:</p>
<p>I don't think your concern is warranted. In the use case that I showed, the comments will be a description about what will immediately follow. It would be there to signify the reader what is going to follow; if it works in the other way, then the content of the comment would be the cause of problem. I am not suggesting to insert irrelevant comments in between a chain. I would go against that.</p>
<p>Regarding your concern: "The next line starting with a dot could be a hundred lines away or a thousand or more lines away.", that is not to blame the syntax. Putting a comment that long in the middle of a chain is a bad coding style, irrespective of whether the next code line starts with a period.</p> Ruby master - Feature #7639: More freedom for location of commentshttps://bugs.ruby-lang.org/issues/7639?journal_id=356272013-01-25T17:35:33Zknu (Akinori MUSHA)knu@ruby-lang.org
<ul></ul><p>It's all about the implementation cost because this is not a bug.<br>
How about taking a glance at the lexer & parser code to see if it's worth it?</p> Ruby master - Feature #7639: More freedom for location of commentshttps://bugs.ruby-lang.org/issues/7639?journal_id=356282013-01-25T18:20:29Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<ul><li><strong>Assignee</strong> set to <i>matz (Yukihiro Matsumoto)</i></li></ul><p>sawa (Tsuyoshi Sawada) wrote:</p>
<blockquote>
<p>duerst:</p>
</blockquote>
<p>(please call me Martin)</p>
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p>Looking at your proposal again, it seems to me that you are saying that this is an inconsistency for people who <em>write</em> 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).</p>
<p>I have assigned this to Matz, because he has the most ability and experience to jugde this kind of writability/readability issue.</p> Ruby master - Feature #7639: More freedom for location of commentshttps://bugs.ruby-lang.org/issues/7639?journal_id=357942013-02-03T14:29:35Zsawa (Tsuyoshi Sawada)
<ul></ul><p>I would like to add another argument for such feature. It is common that you put each step of a chain in a new line. During debugging, it frequently happens that you want to comment out particular lines within a chain. You have no problem when the period is at the end of a line. Below is an example of commenting out <code>method2</code>:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">].</span>
<span class="nf">method1</span><span class="o">.</span>
<span class="c1"># method2{...}.</span>
<span class="n">method3</span><span class="p">(</span><span class="n">arg1</span><span class="p">,</span> <span class="n">arg2</span><span class="p">){</span><span class="o">...</span><span class="p">}.</span>
<span class="nf">method4</span><span class="p">{</span><span class="o">...</span><span class="p">}</span>
</code></pre>
<p>But if you had the periods at the beginning of a line, you cannot do this. The following will not be interpreted with the intended result.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]</span>
<span class="p">.</span><span class="nf">method1</span>
<span class="c1"># .method2{...}</span>
<span class="p">.</span><span class="nf">method3</span><span class="p">(</span><span class="n">arg1</span><span class="p">,</span> <span class="n">arg2</span><span class="p">){</span><span class="o">...</span><span class="p">}</span>
<span class="p">.</span><span class="nf">method4</span><span class="p">{</span><span class="o">...</span><span class="p">}</span>
</code></pre>
<p>Just for the purpose of commenting out <code>method2</code>, you would have to temporarily move the period from the front of <code>method3</code> to the end of <code>method1</code> as so:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]</span>
<span class="p">.</span><span class="nf">method1</span><span class="o">.</span>
<span class="c1"># .method2{...}</span>
<span class="n">method3</span><span class="p">(</span><span class="n">arg1</span><span class="p">,</span> <span class="n">arg2</span><span class="p">){</span><span class="o">...</span><span class="p">}</span>
<span class="p">.</span><span class="nf">method4</span><span class="p">{</span><span class="o">...</span><span class="p">}</span>
</code></pre>
<p>This pretty much discourages programmers to write with the period at the beginning of a line in the first place. It appears to me that such inflexibility with the location of comments makes the feature of allowing the period at the beginning of a line useless.</p> Ruby master - Feature #7639: More freedom for location of commentshttps://bugs.ruby-lang.org/issues/7639?journal_id=358042013-02-03T22:10:30Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul><p>Comments are equivalent to white spaces syntactically now, so do you expect that a method chain will continue beyond empty lines?<br>
It seems strange to me.</p> Ruby master - Feature #7639: More freedom for location of commentshttps://bugs.ruby-lang.org/issues/7639?journal_id=358052013-02-03T22:12:46Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/35805/diff?detail_id=25476">diff</a>)</li></ul> Ruby master - Feature #7639: More freedom for location of commentshttps://bugs.ruby-lang.org/issues/7639?journal_id=358072013-02-03T22:33:47Zsawa (Tsuyoshi Sawada)
<ul></ul><p>Indeed, method chains do seem to continue beyond empty lines. The following two work:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">].</span>
<span class="nf">map</span><span class="p">{</span><span class="o">|</span><span class="n">x</span><span class="o">|</span> <span class="n">x</span> <span class="o">*</span> <span class="mi">2</span><span class="p">}</span>
</code></pre>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]</span><span class="o">.</span>
<span class="c1">#</span>
<span class="n">map</span><span class="p">{</span><span class="o">|</span><span class="n">x</span><span class="o">|</span> <span class="n">x</span> <span class="o">*</span> <span class="mi">2</span><span class="p">}</span>
</code></pre>
<p>But the following does not, (which I claim is strange, given that the above two work):</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]</span>
<span class="c1">#</span>
<span class="p">.</span><span class="nf">map</span><span class="p">{</span><span class="o">|</span><span class="n">x</span><span class="o">|</span> <span class="n">x</span> <span class="o">*</span> <span class="mi">2</span><span class="p">}</span>
</code></pre> Ruby master - Feature #7639: More freedom for location of commentshttps://bugs.ruby-lang.org/issues/7639?journal_id=358112013-02-04T03:44:42Zalexeymuranov (Alexey Muranov)
<ul></ul><p>As for me, i do not like to continue a line by starting the following one with a dot: it is not clear immediately if the first line is over, and does not allow to copy-paste the code into IRB.</p> Ruby master - Feature #7639: More freedom for location of commentshttps://bugs.ruby-lang.org/issues/7639?journal_id=358152013-02-04T11:20:17Zsawa (Tsuyoshi Sawada)
<ul></ul><blockquote>
<p>alexeymuranov (Alexey Muranov)</p>
</blockquote>
<p>Allowing a line to start with a period was a change introduced in Ruby 1.9. It is not what I am newly proposing here. If you are against it, that would be a claim against that feature introduced in the past. My proposal is, provided such feature was introduced, trying to make maximum sense out of it.</p> Ruby master - Feature #7639: More freedom for location of commentshttps://bugs.ruby-lang.org/issues/7639?journal_id=358232013-02-04T14:11:24Zknu (Akinori MUSHA)knu@ruby-lang.org
<ul></ul><p>It was meant to be and has been an experimental feature, so let's not take it for granted as established one.<br>
We already have it so why not extend it is not the way to go.<br>
If a problem is found, we need to reconsider and address downsides before it's too late.</p>
<p>I personally think that this line continuation rule should be withdrawn/obsoleted because it is one of few exceptions that breaks the golden general rule that "If a statement is syntactically complete at a line end, then it is the end of the statement."</p> Ruby master - Feature #7639: More freedom for location of commentshttps://bugs.ruby-lang.org/issues/7639?journal_id=568212016-02-01T09:47:16Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Has duplicate</strong> <i><a class="issue tracker-2 status-5 priority-4 priority-default closed" href="/issues/11678">Feature #11678</a>: ability to comment out methods in a multi-line method chain without needing a new line escape</i> added</li></ul> Ruby master - Feature #7639: More freedom for location of commentshttps://bugs.ruby-lang.org/issues/7639?journal_id=703342018-02-14T06:54:27Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<ul><li><strong>Related to</strong> <i><a class="issue tracker-2 status-1 priority-4 priority-default" href="/issues/14463">Feature #14463</a>: Allow comments to precede dots in member expressions</i> added</li></ul> Ruby master - Feature #7639: More freedom for location of commentshttps://bugs.ruby-lang.org/issues/7639?journal_id=815592019-09-16T12:20:55Zsawa (Tsuyoshi Sawada)
<ul></ul><p>It looks like this feature has been realized by <a href="https://bugs.ruby-lang.org/projects/ruby-trunk/repository/git/revisions/3a3f48fb8fbdbb810d9b675159529970015316b9" class="external">https://bugs.ruby-lang.org/projects/ruby-trunk/repository/git/revisions/3a3f48fb8fbdbb810d9b675159529970015316b9</a><br>
If I am correct, please close this feature, and thanks, nobu-san.</p> Ruby master - Feature #7639: More freedom for location of commentshttps://bugs.ruby-lang.org/issues/7639?journal_id=816112019-09-19T13:44:46Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/81611/diff?detail_id=55092">diff</a>)</li><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Closed</i></li></ul>