April 10, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4532



--- Comment #10 from Kenji Hara <k.hara.pg@gmail.com> 2012-04-09 21:38:54 PDT ---
*** Issue 7881 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 10, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4532



--- Comment #11 from Kenji Hara <k.hara.pg@gmail.com> 2012-04-09 21:40:28 PDT ---
Issue 6595 was a bug report only about std.string.format/sformat functions.

From issue 6595 comment #0:
> This enhancement issue is nearly a bug report.
> 
> format() and sformat() use std.format.doFormat as their implementations, but it
> is old feature, and its features are fewer than formatValue family.
> 
> And it is causing not a few issues:
> bug 3715 - std.string.format can't use const/immutable toString functions
> bug 4266 - add support for structs in std.format.doFormat
> bug 4532 - Position specifiers don't work in format
> bug 5444 - std.string.format: arguments without format specifier appended to
> result
> bug 5970 - fix BigInt.toString
> 
> I think format() should be implemented just appender and formattedWrite like
> follows:
> 
> string format(Char, Args...)(in Char[] fmt, Args args)
> {
>     auto w = appender!string();
>     formattedWrite(w, fmt, args);
>     return w.data;
> }
> 
> This 'format()' provides just the same features as writef(ln) functions about
> formatting.
> 
> And sformat() also could replace like follows:
> 
> char[] sformat(Char, Args...)(char[] buf, in Char[] fmt, Args args)
> {
>     size_t i;
>     void sink(const(char)[] s) {
>         if (buf.length < i + s.length)
>             onRangeError("std.string.sformat", 0);
>         buf[i .. i + s.length] = s[];
>         i += s.length;
>     }
>     formattedWrite(&sink, fmt, args);
>     return buf[0 .. i];
> }

And I proposed a pull and it is discussed in here: https://github.com/D-Programming-Language/phobos/pull/231

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 10, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4532


Stewart Gordon <smjg@iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg@gmx.com


--- Comment #12 from Stewart Gordon <smjg@iname.com> 2012-04-10 03:38:13 PDT ---
*** Issue 4754 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4532



--- Comment #13 from bearophile_hugs@eml.cc 2012-04-20 14:41:35 PDT ---
This seems another example of the same problem:


import std.stdio: writeln;
import std.conv: text;
struct Foo {}
void main() {
    Foo* f = new Foo;
    writeln(f);
    writeln(text(f));
}


Output:

15D2FD0
22884304

Expected output:

15D2FD0
15D2FD0

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4532



--- Comment #14 from bearophile_hugs@eml.cc 2012-04-20 14:49:05 PDT ---
I've taken a look here: https://github.com/D-Programming-Language/phobos/pull/231

Kenji Hara sasy:

>The same name with core.stdc.sprintf is very confusing. And std.string.format returns new string, but core.stdc.sprintf write the formatted string into specified buffer. The two behaviors are quite different.<


Andrei Alexandrescu says:

>There's no problem with core.stdc.sprintf bearing the same name as std.format.sprintf. Phobos has had such duplicate names for years without a problem.<


I agree that Phobos has some name clashes. But I don't agree it's a good thing.
It should be avoided if possible for newly added names.
And I agree the behavior of the new functions is different from the C
functions. So I agree with Kenji Hara, they should have different names.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4532



--- Comment #15 from Stewart Gordon <smjg@iname.com> 2012-04-20 16:29:30 PDT ---
(In reply to comment #13)

text is just to!string wrapped in a variadic template to support multiple arguments.  The implementation of to!string for pointer types (line 1259 in conv.d, in 2.059) converts it to a size_t, which is an integral type, leading to it being formatted as decimal.

I'm not sure whether it's related or not.  But what it does show is that we need to investigate the long chains of template instantiations all these various functions go through.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 25, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4532



--- Comment #16 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-01-24 16:22:09 PST ---
It seems all code samples in this issue are fixed.

There seems to be very few doFormat calls left in Phobos:

std\stdio.d:1498:   std.format.doFormat(&putc, arguments, argptr);
std\stdio.d:1533:   std.format.doFormat(&putcw, arguments, argptr);
std\stream.d:1209:  doFormat(&doFormatCallback,arguments,argptr);

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