[Issue 7348] to!string(null) matches more than one template declaration

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 22 20:44:20 PDT 2012


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



--- Comment #11 from Kenji Hara <k.hara.pg at gmail.com> 2012-05-22 20:45:57 PDT ---
(In reply to comment #10)
[snip]

OK. I found a good reason why we should select "null" as representation of null
literal instead of "".

Now,, to!string(something) is forwarded to formatValue(w, something, fmtspec).
If we select "" (empty string) as the representation, "" should be able to
*unformat* as null lietral. But, 0 length input matches everywhere.
Then we would be able to unformat null value every time.

string input = "";
typeof(null) nullvalue;
formattedRead(input, "%s", &nullvalue);  // read null value from empty input
formattedRead(input, "%s", &nullvalue);  // ditto
formattedRead(input, "%s", &nullvalue);  // ditto
// can repeat infinitely...

This is obviously strange.

Then we should select a representation for null value which has one or more
length string.
So "null" is the best representation for the typeof(null) in D.

-- 
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