Bug 9012 – writef/format inconsistent with format specifier

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-11-12T16:50:00Z
Last change time
2012-12-23T08:17:50Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2012-11-12T16:50:03Z
2.060 and git head: import std.string; import std.stdio; void main() { writefln("Set!%s(%(%s, %))", "int", [1, 2]); // Set!int(1, 2) string s = format("Set!%s(%(%s, %))", "int", [1, 2]); // format error }
Comment #1 by andrej.mitrovich — 2012-11-12T16:51:03Z
xformat works ok though.
Comment #2 by hsteoh — 2012-11-23T16:22:35Z
std.string.xformat is the function that's compatible with std.format. We really should deprecate std.string.format or something, and replace it with xformat. The current std.string.format sucks and every now and then causes newbie confusion when the same format string works in writeln but not in std.string.format (or it works differently).
Comment #3 by andrej.mitrovich — 2012-11-24T01:40:39Z
(In reply to comment #2) > std.string.xformat is the function that's compatible with std.format. We really > should deprecate std.string.format or something, and replace it with xformat. This should be sorted soon enough: https://github.com/D-Programming-Language/phobos/pull/939
Comment #4 by hsteoh — 2012-12-21T07:38:30Z
The pull has been merged; I just tested the code and it's working now. Should this bug be closed?
Comment #5 by k.hara.pg — 2012-12-23T08:17:50Z
OK. Closed.