www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4754] New: format and Format!() do not work with posix positional parameters

reply d-bugmail puremagic.com writes:
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



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: -------
Aug 29 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4754


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 09 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4754


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
                 CC|                            |smjg iname.com
         Resolution|                            |DUPLICATE



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

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