https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112019-08-14T07:00:39ZRuby Issue Tracking SystemRuby master - Feature #16102: `Symbol#call`https://bugs.ruby-lang.org/issues/16102?journal_id=807422019-08-14T07:00:39Zsawa (Tsuyoshi Sawada)
<ul></ul><p>Related to <a class="issue tracker-2 status-6 priority-4 priority-default closed" title="Feature: Array::zip (Rejected)" href="https://bugs.ruby-lang.org/issues/6499">#6499</a>, <a class="issue tracker-2 status-7 priority-4 priority-default closed" title="Feature: Add Array#rest (with implementation) (Feedback)" href="https://bugs.ruby-lang.org/issues/6727">#6727</a>, <a class="issue tracker-2 status-1 priority-4 priority-default" title="Feature: Array#product_set (Open)" href="https://bugs.ruby-lang.org/issues/7444">#7444</a>, <a class="issue tracker-2 status-1 priority-4 priority-default" title="Feature: Array.zip and Array.product (Open)" href="https://bugs.ruby-lang.org/issues/8970">#8970</a>, <a class="issue tracker-2 status-1 priority-4 priority-default" title="Feature: Make more objects behave like "Functions" (Open)" href="https://bugs.ruby-lang.org/issues/11262">#11262</a>.</p> Ruby master - Feature #16102: `Symbol#call`https://bugs.ruby-lang.org/issues/16102?journal_id=807442019-08-14T07:24:53Zsawa (Tsuyoshi Sawada)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/80744/diff?detail_id=54354">diff</a>)</li></ul> Ruby master - Feature #16102: `Symbol#call`https://bugs.ruby-lang.org/issues/16102?journal_id=807462019-08-14T07:29:39Zsawa (Tsuyoshi Sawada)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/80746/diff?detail_id=54356">diff</a>)</li></ul> Ruby master - Feature #16102: `Symbol#call`https://bugs.ruby-lang.org/issues/16102?journal_id=807482019-08-14T08:37:21Zshevegen (Robert A. Heiler)shevegen@gmail.com
<ul></ul><p>I have no particular pro/con opinion on the suggested functionality here itself.</p>
<p>In my opinion, this is mostly a design consideration for how "useful" matz<br>
wants to see symbols being used in ruby. (This may not be directly related<br>
to the comment here, but more generally in how simple, complex or useful<br>
matz may want to see symbols.)</p>
<p>On a side note, it is (to me) interesting that sawa is not the only one<br>
with somewhat related ideas in this regard, as he has pointed out via<br>
mentioning <a href="https://bugs.ruby-lang.org/issues/12115" class="external">https://bugs.ruby-lang.org/issues/12115</a>. :)</p> Ruby master - Feature #16102: `Symbol#call`https://bugs.ruby-lang.org/issues/16102?journal_id=807502019-08-14T09:00:30Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul></ul><p>I agree that <code>ary1.zip(ary2, ary3)</code> is asymmetric and uncool, but I don't like solving the issue by adding a method of Symbol. <code>:zip.(*arrays)</code> looks too cryptic and semantically hacky to me. Rather, I like your <a class="issue tracker-2 status-1 priority-4 priority-default" title="Feature: Array.zip and Array.product (Open)" href="https://bugs.ruby-lang.org/issues/8970">#8970</a>: <code>Array.zip(ary1, ary2, ary3)</code>. It is much simpler, clearer, and easier to understand.</p> Ruby master - Feature #16102: `Symbol#call`https://bugs.ruby-lang.org/issues/16102?journal_id=815342019-09-12T09:25:43Zinopinatus (Joshua GOODALL)
<ul></ul><p>I propose this general solution.</p>
<pre><code>diff --git a/array.c b/array.c
index 3717c3ff34..3809af01cf 100644
--- a/array.c
+++ b/array.c
@@ -6988,6 +6988,7 @@ Init_Array(void)
rb_define_method(rb_cArray, "dig", rb_ary_dig, -1);
rb_define_method(rb_cArray, "sum", rb_ary_sum, -1);
+ rb_define_method(rb_cArray, "splat", rb_yield_splat, 0);
rb_define_method(rb_cArray, "deconstruct", rb_ary_deconstruct, 0);
id_random = rb_intern("random");
</code></pre>
<p>then:</p>
<pre><code>arrays = [["a", "b"], ["c"], ["d", "e"]]
arrays.splat(&:product)
#=> [["a", "c", "d"], ["a", "c", "e"], ["b", "c", "d"], ["b", "c", "e"]]
</code></pre>