| |
 | Posted by Jonathan M Davis | Permalink Reply |
|
Jonathan M Davis 
| http://d.puremagic.com/issues/show_bug.cgi?id=4754
Summary: format and Format!() do not work with posix positional
parameters
Product: D
Version: D2
Platform: Other
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody@puremagic.com
ReportedBy: jmdavisProg@gmail.com
--- Comment #0 from Jonathan M Davis <jmdavisProg@gmail.com> 2010-08-29 03:29:49 PDT ---
The following program fails to compile:
import std.metastrings;
import std.stdio;
void main()
{
mixin(Format!("writeln(\"%1$s\");", "hello world"));
}
Instead, you get this error:
/path/to/src/phobos/std/metastrings.d(69): Error: static assert "unrecognized
format %1"
/path/to/src/phobos/std/metastrings.d(51): 11 recursive instantiations
from here: FormatString!("writeln(\"%1$s\");","hello world")
d.d(6): instantiated from here: Format!("writeln(\"%1$s\");","hello
world")
So, it would appear that Format!() fails to work with posix positional parameters. If you replace %1$s with %s, it works just fine. Also, if you attempt to use format() with %1$s, it throws a FormatError at runtime. I would expect that format and Format!() would accept exactly the same types of input as writefln(). However, that does not appear to currently be the case. Certainly, having them differ in capabilities is going to cause a fair bit of confusion. So, they need to be fixed to work with the same input as writefln(). In particular, they need to support posix positional parameters.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
|