[Issue 5970] format(%d, BigInt) problem

2011-08-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5970



--- Comment #1 from bearophile_h...@eml.cc 2011-08-24 18:59:13 PDT ---
import std.bigint, std.conv;
void main() {
string s = text(BigInt(1));
}


In DMD 2.055beta it gives:

...\src\phobos\std\conv.d(829): Error: function std.bigint.BigInt.toString
(void delegate(const(char)[]) sink, string formatString) const is not callable
using argument types ()
...\src\phobos\std\conv.d(829): Error: expected 2 function arguments, not 0


See also notes in bug 4122 :

My suggestion is to change the signature of BigInt.toString() from this:

void toString(void delegate(const (char)[]) sink, string formatString) const {


To something like this:

string toString(void delegate(string) sink=null, string formatString=d) const
{   

And make it return a string filled with the decimal representation when sink is
null; and to return an empty string when sink!=null.



Eventually the signature can even become:

string toString(void delegate(string) sink=null, string formatString=d,
string thousands=) const {

So if thousands=_ the number gets represented as:

100_000_000_000

But this is less essential.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5970] format(%d, BigInt) problem

2011-08-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5970


timon.g...@gmx.ch changed:

   What|Removed |Added

 CC||timon.g...@gmx.ch


--- Comment #2 from timon.g...@gmx.ch 2011-08-24 19:38:02 PDT ---
alternatively, just provide another overload.

bi.toString(), where bi is a BigInt should just work and return a newly
allocated string that represents bi.

(The current toString would actually better be called writeTo. Format string
should default to null in each case.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---