From: Aaron Patterson Date: 2011-01-11T13:09:07+09:00 Subject: [ruby-core:34326] Re: ext/bigdecimal/lib/bigdecimal/util.rb --/04w6evG8XlLl3ft Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jan 11, 2011 at 11:35:31AM +0900, Yukihiro Matsumoto wrote: > Hi, >=20 > In message "Re: [ruby-core:34318] ext/bigdecimal/lib/bigdecimal/util.rb" > on Tue, 11 Jan 2011 09:17:15 +0900, Aaron Patterson writes: >=20 > |It looks like ext/bugdecimal/lib/bigdecimal/util.rb is only > |conditionally required by bigdecimal.c: > | > | https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1= 48-151 > | > |Could we possibly change this to just require 'util.rb' all the time? >=20 > I'd rather like to remove the dependency of util.rb from the > bigdecimal core. >=20 > |Also, it looks like bigdecimal defines `to_d` on a few classes, but not > |itself. It would be nice if we could call `to_d` on all Numeric > |objects as well as BigDecimal objects. >=20 > I agree with this patch, only when bigdecimal/util is explicitly > loaded. In fact, I don't want to see no more to_x (x is any single > character) conversion methods in the core libraries. I completely agree. I don't want to see more to_* methods. My problem is that I need to convert some numeric(ish) objects to BigDecimal. BigDecimal.new() only accepts strings, which is OK. But I don't want to convert objects to strings if they are already BigDecimal objects. I also don't want to perform the is_a?() check before calling to_s. It would be nice if I could do: BigDecimal.new(10) # =3D> # BigDecimal.new(10.to_s) # =3D> # BigDecimal.new(10.1) # =3D> # BigDecimal.new(BigDecimal.new(10)) # =3D> # I can provide a patch for this functionality too, if it seems good. --=20 Aaron Patterson http://tenderlovemaking.com/ --/04w6evG8XlLl3ft Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iQEcBAEBAgAGBQJNK9fdAAoJEJUxcLy0/6/GMu0H/RXlyKoWPFlH6T1WK3Lo9BG/ WSouNtzp+BdRVTj4n7w4l+5dC27E+6rsxS7j3EJ8V1J5pzCH2ZDeVIex+V3xOsDl 6kIg+/0TEjPfzJDgr4Zpcdi6ZoPeqUOd7wTX9hxdbekCeuhFRrI7dCeqiAhDpxIn znYI6bPdJdBh1Ajd91sdjFxngn74FcDc5AFIY3kG+VC0ogZK6quAZcW2iAuLmKS2 rlpJ06cMAWvjwD97YLk4R5LDW11Met1QbcFbV1tx71Tm07HrtPLWCPhqfxv2LD6r qLkMLDx+HRExHipVuujdukSuIfITkp0Oz6MZESaQLxJi0yUXHtzrophDOgAqUYE= =/f73 -----END PGP SIGNATURE----- --/04w6evG8XlLl3ft--