https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112020-05-17T06:16:20ZRuby Issue Tracking SystemRuby master - Feature #16898: Modify the syntax of -> lambda expressions in ruby3https://redmine.ruby-lang.org/issues/16898?journal_id=856752020-05-17T06:16:20Zjackmaple (maple jack)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/85675/diff?detail_id=57067">diff</a>)</li></ul> Ruby master - Feature #16898: Modify the syntax of -> lambda expressions in ruby3https://redmine.ruby-lang.org/issues/16898?journal_id=856762020-05-17T07:21:06Zjackmaple (maple jack)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/85676/diff?detail_id=57068">diff</a>)</li></ul> Ruby master - Feature #16898: Modify the syntax of -> lambda expressions in ruby3https://redmine.ruby-lang.org/issues/16898?journal_id=856772020-05-17T07:55:57Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul></ul><p>"Ugliness is in the eye of the beholder". Could you explain why the current syntax is ugly?</p>
<p>In any case, if we change the syntax, all Ruby programs that use the current <strong>ugly</strong> lambda syntax no longer work. How do you think? Is it worth the pain of the whole Ruby community?</p>
<p>Matz.</p> Ruby master - Feature #16898: Modify the syntax of -> lambda expressions in ruby3https://redmine.ruby-lang.org/issues/16898?journal_id=856822020-05-17T18:03:58Zshan (Shannon Skipper)
<ul></ul><p>To me, this</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="o">-></span> <span class="n">lightness</span> <span class="p">{</span> <span class="n">lightness</span> <span class="p">}</span>
</code></pre>
<p>Is prettier than</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">lambda</span> <span class="p">{</span> <span class="o">|</span><span class="n">lightness</span><span class="o">|</span> <span class="n">lightness</span> <span class="p">}</span>
</code></pre>
<p>¯\<em>(ツ)</em>/¯</p>
<p>I like stabby lambdas, but it doesn't seem worth the pain of the massive code breakage even if we all agreed they're ugly.</p> Ruby master - Feature #16898: Modify the syntax of -> lambda expressions in ruby3https://redmine.ruby-lang.org/issues/16898?journal_id=856872020-05-17T21:50:28Z0x81000000 (/ /)
<ul></ul><p>matz (Yukihiro Matsumoto) wrote in <a href="#note-3">#note-3</a>:</p>
<blockquote>
<p>"Ugliness is in the eye of the beholder".</p>
</blockquote>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="o">-></span> <span class="p">(;</span><span class="n">x</span><span class="p">)</span> <span class="p">{</span> <span class="n">x</span> <span class="o">=</span> <span class="mi">1</span> <span class="p">}</span> <span class="c1"># correct</span>
<span class="o">-></span> <span class="p">;</span><span class="n">x</span> <span class="p">{</span> <span class="n">x</span> <span class="o">=</span> <span class="mi">1</span> <span class="p">}</span> <span class="c1"># syntax error</span>
</code></pre>
<p>Is the second uglier?</p> Ruby master - Feature #16898: Modify the syntax of -> lambda expressions in ruby3https://redmine.ruby-lang.org/issues/16898?journal_id=856882020-05-17T23:04:46Zjackmaple (maple jack)
<ul></ul><p>matz (Yukihiro Matsumoto) wrote in <a href="#note-3">#note-3</a>:</p>
<blockquote>
<p>"Ugliness is in the eye of the beholder". Could you explain why the current syntax is ugly?</p>
<p>In any case, if we change the syntax, all Ruby programs that use the current <strong>ugly</strong> lambda syntax no longer work. How do you think? Is it worth the pain of the whole Ruby community?</p>
<p>Matz.</p>
</blockquote>
<p>Hello, we currently have lambda syntax, but at present-> seems to be just a simplified alternative,-> The braces behind cannot be omitted when there is only one line of statement, maybe we can add a new lambda syntax, thank you</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1">#1 -> x {x}</span>
<span class="c1">#2 x -> x</span>
</code></pre>
<p>I think the second way of writing can omit curly braces in only one expression.Of course this is just my suggestion,I respect your decision.thank you very much.</p> Ruby master - Feature #16898: Modify the syntax of -> lambda expressions in ruby3https://redmine.ruby-lang.org/issues/16898?journal_id=856922020-05-18T01:19:40Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul></ul><p>Not going to join the ugliness debate but I doubt if the proposed new syntax technically possible. It would be much convincing if you provide a working pull request.</p> Ruby master - Feature #16898: Modify the syntax of -> lambda expressions in ruby3https://redmine.ruby-lang.org/issues/16898?journal_id=856952020-05-18T08:27:04Zjackmaple (maple jack)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/85695/diff?detail_id=57071">diff</a>)</li></ul> Ruby master - Feature #16898: Modify the syntax of -> lambda expressions in ruby3https://redmine.ruby-lang.org/issues/16898?journal_id=856962020-05-18T08:30:24Zjackmaple (maple jack)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/85696/diff?detail_id=57072">diff</a>)</li></ul> Ruby master - Feature #16898: Modify the syntax of -> lambda expressions in ruby3https://redmine.ruby-lang.org/issues/16898?journal_id=856972020-05-18T08:36:30Zjackmaple (maple jack)
<ul></ul><p>Maybe my expression has some problems, sorry, it has been modified, in fact, what I want to say is that the existing lambda expression looks like the arrow symbol is not very intuitive.<br>
If we can simplify the grammar, in some cases it would be better to remove the braces?</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="o">-></span> <span class="n">x</span> <span class="n">x</span> <span class="c1"># error</span>
<span class="o">-></span> <span class="n">x</span> <span class="p">{</span><span class="n">x</span><span class="p">}</span> <span class="c1"># correct</span>
</code></pre>
<p>So it would be better if we could provide a grammar with braces removed?In order to maintain compatibility, it is not necessary to modify the existing grammar.<br>
For example, add a new lambda operator "==>"?</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="o">-></span> <span class="n">x</span> <span class="p">{</span><span class="n">x</span><span class="p">}</span>
<span class="nb">lambda</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="p">}</span>
<span class="n">x</span> <span class="o">==></span> <span class="n">x</span> <span class="c1"># suppose</span>
</code></pre>
<p>What do you think?<br>
thanks.</p> Ruby master - Feature #16898: Modify the syntax of -> lambda expressions in ruby3https://redmine.ruby-lang.org/issues/16898?journal_id=857092020-05-19T02:02:43Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul></ul><p>I get your point. But to my eyes, <code>==></code> is even uglier. It's easily confused with other operators which do not correspond with lambdas but association operators (hash rockets) or comparison operators.<br>
I am not yet convinced having a new lambda operator without braces around the body is <strong>that</strong> important, despite the possibility of the above confusion.</p>
<p>Matz.</p>