November 18, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5231



--- Comment #10 from Steven Schveighoffer <schveiguy@yahoo.com> 2010-11-18 10:20:08 PST ---
(In reply to comment #9)
> 
> If it was just a question of inefficiency, I would have implemented it. The
> issue is that it doesn't get the formatting string.
> So
> BigInt b;
> writefln("%x %+d", b, b);
> 
> doesn't work, and cannot be made to work.

But what about writeln, or writefln("%s"...) ?  Should those usages be excluded because you can't have custom formatting?

> No. The format string is absolutely fundamental to the implementation of outputting BigInt and BigFloat. It's not just "a crap implementation".

I disagree here.  The huge problem I have with toString is the requirement for allocating immutable data that immediately gets thrown away.  Supporting custom formatting is a nice feature but not having it does not severely impact users nearly as much as not having any output.  In other words, if I want to print a BigInt in hex, and I get "BigInt", that is useless to me.  If I get it in decimal, well at least I got something that can be used.

If the format string is so fundamental, then why does BigInt.toString support a null format argument?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 18, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5231



--- Comment #11 from Don <clugdbug@yahoo.com.au> 2010-11-18 12:01:39 PST ---
(In reply to comment #10)
> (In reply to comment #9)
> > 
> > If it was just a question of inefficiency, I would have implemented it. The
> > issue is that it doesn't get the formatting string.
> > So
> > BigInt b;
> > writefln("%x %+d", b, b);
> > 
> > doesn't work, and cannot be made to work.
> 
> But what about writeln, or writefln("%s"...) ?  Should those usages be excluded because you can't have custom formatting?

Yes.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 18, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5231



--- Comment #12 from Jonathan M Davis <jmdavisProg@gmx.com> 2010-11-18 12:31:36 PST ---
So, you don't want writeln(bi); or to!string(bi) to work? I would think that
ideally, BigInt would work exactly the same way that integers do.

to!string(i) -> decimal
writeln(i) -> decimal
writefln("%s", i) -> decimal
writefln("%d", i) -> decimal
writefln("%f", i) -> hex


So, ideally, BigInt would do the same:

to!string(bi) -> decimal
writeln(bi) -> decimal
writefln("%s", bi) -> decimal
writefln("%d", bi) -> decimal
writefln("%f", bi) -> hex


But you only want this?:

writefln("%d", bi) -> decimal
writefln("%f", bi) -> hex


Okay. I can see an argument for a better handling of toString() in general (I'd
never even heard anyone complain about string toString() or discuss the
possibility of a void toString() before the discussion on this bug report) and
that to!string(), writeln(), writefln(), etc. need to be fixed to support a
void toString() instead of string toString(), but I don't understand why you
would refuse to allow for BigInt to be convertible to a string or printed as
one without a format string. I don't see why it shouldn't act the same way that
all of the built-in integral values do in this regard.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 18, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5231



--- Comment #13 from Jonathan M Davis <jmdavisProg@gmx.com> 2010-11-18 12:33:01 PST ---
Whoops. I meant %x, not %f for hex. Sorry about that.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 18, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5231



--- Comment #14 from Don <clugdbug@yahoo.com.au> 2010-11-18 13:39:08 PST ---
(In reply to comment #12)
> So, you don't want writeln(bi); or to!string(bi) to work?

No, that's not what I meant.

> I would think that
> ideally, BigInt would work exactly the same way that integers do.
> 
> to!string(i) -> decimal
> writeln(i) -> decimal
> writefln("%s", i) -> decimal
> writefln("%d", i) -> decimal
> writefln("%f", i) -> hex
> 
> 
> So, ideally, BigInt would do the same:
> 
> to!string(bi) -> decimal
> writeln(bi) -> decimal
> writefln("%s", bi) -> decimal
> writefln("%d", bi) -> decimal
> writefln("%f", bi) -> hex

Yes. The thing I do *not* want is where it works for one case but not any of the others. I find that suggestion completely indefensible.

BTW, the void toString() was just a typo by me. I meant string toString().

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 18, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5231



--- Comment #15 from Jonathan M Davis <jmdavisProg@gmx.com> 2010-11-18 14:32:17 PST ---
Well, then I think that we agree on the desired eventual functionality. But I do think that in the interim, it would be a good idea to add string toString() to BigInt with the idea that it would be removed as soon as the fancier toString() stuff is sorted out. That way, at least _some_ of the desired behavior would work rather than forcing you to call the current toString() with a delegate just to get a string representation for a BigInt.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 19, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5231


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #16 from Don <clugdbug@yahoo.com.au> 2010-11-19 01:27:43 PST ---
This is a bug in format. Even the partial fix I made for bug 5237, makes BigInt print correctly, without any change to the BigInt code.

*** This issue has been marked as a duplicate of issue 5237 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 19, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5231



--- Comment #17 from bearophile_hugs@eml.cc 2010-11-19 07:14:29 PST ---
(In reply to comment #16)
> This is a bug in format. Even the partial fix I made for bug 5237, makes BigInt print correctly, without any change to the BigInt code.
> 
> *** This issue has been marked as a duplicate of issue 5237 ***

See also: http://d.puremagic.com/issues/show_bug.cgi?id=4122

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
1 2
Next ›   Last »