[#68478] Looking for MRI projects for Ruby Google Summer of Code 2015 — Tony Arcieri <bascule@...>

Hi ruby-core,

10 messages 2015/03/10

[ruby-core:68392] [Ruby trunk - Bug #10924] String#b

From: duerst@...
Date: 2015-03-03 08:10:26 UTC
List: ruby-core #68392
Issue #10924 has been updated by Martin D端rst.


Thomas Sawyer wrote:
> Well, I just learned about the String#b [method](http://ruby-doc.org/core-2.1.0/String.html#methodi-b) today. And of course it breaks the [Radix](https://github.com/rubyworks/radix) gem :-(  Honestly, back when I create Radix in 2009 I could not have imagined a safer bet than `#b` for an extension if I tried.

Essentially, no name is safe. However well you may try, you may have bad luck.


> And yet sure enough, Ruby makes `String#b` an official method for converting to ASCII 8-bit. Is it really such a popular method to get such a short name? I mean `String#ascii` wouldn't have been a better choice? To go along with `#ascii_only`?

It's actually short because it's supposed to be syntactic sugar, somewhat similar to the options on a Regexp literal.


> Okay, so much for my mini-rant. So bottom line, can I ask that this method not be called `#b`? Even putting the conflict with Radix aside, I think it's a pretty bad name for a standard Ruby method. Just read it: "#b". Do you have any idea what that does without looking it up in the documentation? Nope, no way.

That's a valid point, but it would also apply to your use of #b in Radix, wouldn't it? It may just be me, but I'd have more of an idea what's going on for
[100,10].base(256).to_a(10)
than for
[100,10].b(256).to_a(10)


----------------------------------------
Bug #10924: String#b
https://bugs.ruby-lang.org/issues/10924#change-51741

* Author: Thomas Sawyer
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 2.1.0
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Well, I just learned about the String#b [method](http://ruby-doc.org/core-2.1.0/String.html#methodi-b) today. And of course it breaks the [Radix](https://github.com/rubyworks/radix) gem :-(  Honestly, back when I create Radix in 2009 I could not have imagined a safer bet than `#b` for an extension if I tried. And yet sure enough, Ruby makes `String#b` an official method for converting to ASCII 8-bit. Is it really such a popular method to get such a short name? I mean `String#ascii` wouldn't have been a better choice? To go along with `#ascii_only`?

Okay, so much for my mini-rant. So bottom line, can I ask that this method not be called `#b`? Even putting the conflict with Radix aside, I think it's a pretty bad name for a standard Ruby method. Just read it: "#b". Do you have any idea what that does without looking it up in the documentation? Nope, no way. 

(P.S. Bug or feature, not sure what to label it. Left it a bug b/c it did [break people's code](https://github.com/rubyworks/radix/issues/10).)



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

In This Thread

Prev Next