[#47409] [ruby-trunk - Feature #6973][Open] Add an #integral? method to Numeric to test for whole-number values — "regularfry (Alex Young)" <alex@...>

12 messages 2012/09/03

[#47481] [ruby-trunk - Bug #7008][Open] rake is crashing when trying to compile ffi gem — "drookie (Eugene M. Zheganin Eugene M. Zheganin)" <eugene@...>

10 messages 2012/09/12

[#47505] [ruby-trunk - Feature #7019][Open] allow `private` and `protected` keywords to take blocks — "alexeymuranov (Alexey Muranov)" <redmine@...>

15 messages 2012/09/13

[#47582] [ruby-trunk - Bug #7037][Open] float formatting inconsistently rounds half to even — "headius (Charles Nutter)" <headius@...>

14 messages 2012/09/19

[#47638] [ruby-trunk - Bug #7046][Open] ERB#run and ERB#result are not safe for concurrent use — "headius (Charles Nutter)" <headius@...>

11 messages 2012/09/21

[#47655] [ruby-trunk - Feature #7051][Open] Extend caller_locations API to include klass and bindings. Allow caller_locations as a method hanging off Thread. — "sam.saffron (Sam Saffron)" <sam.saffron@...>

13 messages 2012/09/23

[#47657] [ruby-trunk - Feature #7055][Open] Allow `.foo=` as a synonym of `self.foo=` — "alexeymuranov (Alexey Muranov)" <redmine@...>

11 messages 2012/09/23

[#47730] [ruby-trunk - Bug #7085][Open] Subversion → GitHub gateway stops. — "shyouhei (Shyouhei Urabe)" <shyouhei@...>

27 messages 2012/09/29

[#47735] [ruby-trunk - Bug #7087][Open] ::ConditionVariable#wait does not work with Monitor because Monitor#sleep does not exist — "rklemme (Robert Klemme)" <shortcutter@...>

10 messages 2012/09/29

[#47759] [ruby-trunk - Bug #7092][Open] StringScanner start-of-line matches false positives, while lookbehind for a newline gives false negatives — "jayferd (Jay Adkisson)" <jjmadkisson@...>

8 messages 2012/09/30

[ruby-core:47455] Re: [ruby-trunk - Bug #6994][Open] yield plus splat unwraps too much

From: Tanaka Akira <akr@...>
Date: 2012-09-08 00:30:40 UTC
List: ruby-core #47455
2012/9/8 headius (Charles Nutter) <headius@headius.com>:

> Bug #6994: yield plus splat unwraps too much
> https://bugs.ruby-lang.org/issues/6994

> system ~/projects/jruby $ ruby-1.8.7-p358 -e "def foo; yield *[[1]]; end; foo {|a, b, *c| p [a,b,c]}"
> [[1], nil, []]

This behavior causes "yield *[[1]]" and "yield [1]" is different:

  % ruby-1.8 -e "def foo; yield *[[1]]; end; foo {|a, b, *c| p [a,b,c]}"
  [[1], nil, []]
  % ruby-1.8 -e "def foo; yield [1]; end; foo {|a, b, *c| p [a,b,c]}"
  [1, nil, []]
  % ruby-1.8 -v
  ruby 1.8.8dev (2012-05-21 revision 26840) [x86_64-linux]

So, information passed by yield to a block is not only
a list of values but also something differentiate the above behaviors.

It makes us impossible to pass block arguments as follows:

  def test()
    m() {|*vals| yield(*vals) }
  end

This passes only a list of values from test() to m().
So the information for "something differentiate the above behaviors"
is discarded.

> system ~/projects/jruby $ ruby-1.9.3 -e "def foo; yield *[[1]]; end; foo {|a, b, *c| p [a,b,c]}"
> [1, nil, []]

Since Ruby 1.9, information passed by yield to a block is only
a list of values.

So "yield *[[1]]" and "yield [1]" behaves same:

  % ruby -e "def foo; yield *[[1]]; end; foo {|a, b, *c| p [a,b,c]}"
  [1, nil, []]
  % ruby -e "def foo; yield [1]; end; foo {|a, b, *c| p [a,b,c]}"
  [1, nil, []]
  % ruby -v
  ruby 2.0.0dev (2012-08-15 trunk 36702) [x86_64-linux]

Splat works in callee side.  It expands single array.
It cannot distinguish "yield *[[1]]" and "yield [1]".

> JRuby behaves like 1.8 in both 1.8 and 1.9 modes. I would feel pretty dirty fixing it, since I think the 1.9.3/2.0.0 behavior is wrong.

I don't think Ruby 1.9 behavior is wrong.
-- 
Tanaka Akira

In This Thread