[Issue 8384] std.conv.to should allow conversion between any pair of string/wstring/dstring/char*/wchar*/dchar*

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Aug 15 13:48:34 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8384



--- Comment #11 from Vladimir Panteleev <thecybershadow at gmail.com> 2012-08-15 13:48:30 PDT ---
Sorry, I don't think that your categorical point of view is constructive. As
long as D will interface with C libraries and programs, people will continue to
attempt to use C strings together or in place of D strings, and issues like the
above will continue to appear.

How often would a typical D user want to print / format the address of a
character, versus the null-terminated string at that address?

> It would be a huge mistake IMHO to support doing _anything_ with character
> pointers which treats them as strings without requiring an explicit conversion
> of some kind. 

Why would it be a mistake? What exactly do we lose by allowing writeln/format
to understand C strings?

> Anyone who continues to think of char* as being a string in D is
> just asking for trouble.

What kind of trouble?

> They need to learn to use strings correctly.

D printing an address when text was expected will sooner generate a "D sucks"
reaction than a "Oops, I need to learn to use strings correctly" one.

> If you really want to use char* as a string in functions like format or
writeln, then simply either use to!string or ptr[0 .. strln(ptr)].

That's not really simple, considering some spots where that (verbose)
modification needs to be made would be discovered only late at runtime, and
even then the actual problem is not obvious to identify (as seen in the SO
question above).

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


More information about the Digitalmars-d-bugs mailing list