www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4527] New: writeln/typeid to use string type names

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

           Summary: writeln/typeid to use string type names
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



This is a D2 program:

import std.stdio: writeln;
void main() {
    writeln(typeid(string));
    writeln(typeid(wstring));
    writeln(typeid(dstring));
}


I'd like the output of that program to be:

string
wstring
dstring

Instead of (dmd 2.047):

immutable(char)[]
immutable(wchar)[]
immutable(dchar)[]


"immutable(dchar)[]" is less readable, and dstring is a standard built-in alias
in D2.

Making them readable is especially important when string types are inside more
complex types, to decrease the visual noise a lot. Example:

import std.stdio;
void main() {
    wstring[string[dstring]] a;
    writeln(typeid(typeof(a)));
}

Prints an unreadable:
immutable(wchar)[][const(immutable(char)[])[immutable(dchar)[]]]

While this is almost readable still:
wstring[string[dstring]]


See also bug 3086

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 28 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4527


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com
          Component|Phobos                      |druntime



07:18:41 PDT ---
I don't like special-casing, but I do agree the output would be more readable.
Perhaps we need to introduce a new function that outputs a more readable string
representation. Not sure..

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 26 2013