[#41916] Proposal: Bitmap Marking GC — Narihiro Nakamura <authornari@...>

Hi.

18 messages 2012/01/05

[#41941] [ruby-trunk - Bug #5851][Open] make check fails when compiling with GCC 4.7 - *** longjmp causes uninitialized stack frame *** — Vit Ondruch <v.ondruch@...>

12 messages 2012/01/06

[#41979] [ruby-trunk - Bug #5865][Open] Exception#== should return false if the classes differ — Hiro Asari <asari.ruby@...>

10 messages 2012/01/08

[#42003] [ruby-trunk - Bug #5871][Open] regexp \W matches some word characters when inside a case-insensitive character class — Gareth Adams <gareth@...>

14 messages 2012/01/09

[#42016] [ruby-trunk - Feature #5873][Open] Adopt FFI over DL — Heesob Park <phasis@...>

15 messages 2012/01/10

[#42149] [ruby-trunk - Feature #5899][Open] chaining comparsions. — Ondrej Bilka <neleai@...>

12 messages 2012/01/16

[#42164] [ruby-trunk - Feature #5903][Open] Optimize st_table (take 2) — Yura Sokolov <funny.falcon@...>

18 messages 2012/01/17

[ruby-core:42218] [ruby-trunk - Bug #5915][Assigned] Array#join with explicit nil should not use $,

From: Yui NARUSE <naruse@...>
Date: 2012-01-23 06:29:51 UTC
List: ruby-core #42218
Issue #5915 has been updated by Yui NARUSE.

Status changed from Open to Assigned
Assignee set to Yukihiro Matsumoto

Marc, thank you for clarification.

Marc-Andre Lafortune wrote:
> As Yui points out, the documentation doesn't state *explicitly* how `nil` is treated.

Yes.

> On the other hand, I agree with John that the current behaviour is not intuitive and that either the documentation should be clarified or the behaviour should be changed.
> 
> 1) To explicitly describe the current behavior, the documentation needs to state that if `sep` is `nil`, then `$,` is used **and that if `$,` is `nil`, then no separator is used**. This last part is also needed, because currently `Array#join` does not call `#to_s` on `sep`, so `nil` is actually a special value.

Yes, there is this option.
People  must show the reason against this.

> Or else:
> 2) The current behavior so that `sep == nil` means that there will be no separator. Documentation could state this explicitly by saying that "... separated by +sep+ (if non-nil)". Clearly, the shorter documentation reflects the fact that this is simpler. I believe this is what John suggests.
> 
> 3) The behaviour could also be changed so that `Array#join` calls `#to_s` on `sep`, like it does on its members. Most Ruby functions only call `to_str` on the arguments, but `Array#join` calls `to_s` on the elements of the array, so it's not clear (to me) why it doesn't on `sep` (maybe Matz has an idea?). In that case, the behavior would match what John and I favor, and the documentation doesn't really need to change or could state that "elements and `sep` will be converted to strings if need be by calling `to_s`".
> 
> I personally favor (2) or (3), so that:
> 
>     $, = "foo"
>     [4,2].join(nil) == "42"
> 
> Yui, do you prefer the current behavior where the result is "4foo2"?

nil is a special value so that it can occur some special behavior.
The point seems the difference between $,=nil and sep=nil, feel strange.
----------------------------------------
Bug #5915: Array#join with explicit nil should not use $,
https://bugs.ruby-lang.org/issues/5915

Author: John Firebaugh
Status: Assigned
Priority: Normal
Assignee: Yukihiro Matsumoto
Category: 
Target version: 
ruby -v: ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]


=begin
The documentation for Array#join says that the default argument is $,. But:

  $, = ","
  [1,2,3].join(nil) #=> "1,2,3"

Based on the documentation (and the POLS), I would expect "123".
=end



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

In This Thread