www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11782] New: format pointer to range prints range

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11782

           Summary: format pointer to range prints range
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: monarchdodra gmail.com



//----
import std.string;
void main()
{
    auto  a  = iota(0, 10);
    auto  p  = &a;
    writefln("%s", a);
    writefln("%s", p);
}
//----
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
//----

This is not documented behavior. The documented behavior is simply:
"Pointers are formatted as hex integers."

The current behavior (pointer to ranges prints the range) makes no sense to me,
and I don't see why a pointer to such a type would get a special treatment.

I think this behavior is wrong, and should be removed to simply treat the
pointer as a pointer.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 19 2013
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11782


Dmitry Olshansky <dmitry.olsh gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmitry.olsh gmail.com



14:01:16 PST ---


 This is not documented behavior. The documented behavior is simply:
 "Pointers are formatted as hex integers."
The fun is that a pointer to a range is a range. It naturally supports all of primitives.
 I think this behavior is wrong, and should be removed to simply treat the
 pointer as a pointer.
Maybe. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 19 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11782






 
 This is not documented behavior. The documented behavior is simply:
 "Pointers are formatted as hex integers."
The fun is that a pointer to a range is a range. It naturally supports all of primitives.
Almost ;) https://d.puremagic.com/issues/show_bug.cgi?id=11779 //---- import std.string; void main() { auto a = iota(0, 10).array(); auto p = &a; writefln("%s", a); writefln("%s", p); } //---- [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 7FFF0ABA5FA0 //---- -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 19 2013
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11782






 
 This is not documented behavior. The documented behavior is simply:
 "Pointers are formatted as hex integers."
The fun is that a pointer to a range is a range. It naturally supports all of primitives.
Also (but off topic here), while the slicing operator is still supported, the slice-able *trait* becomes lost, as the returned type (R) won't match the used type (R*). -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 19 2013