May 22, 2012 [Issue 7348] to!string(null) matches more than one template declaration | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mariusz Gliwiński | http://d.puremagic.com/issues/show_bug.cgi?id=7348 --- Comment #10 from bearophile_hugs@eml.cc 2012-05-22 13:54:53 PDT --- Now this code: import std.conv, std.stdio; void main() { writeln(">", to!string(null), "<"); } Prints: >< But I expect something similar to: >null< ------------------------- This code: import std.stdio; void main() { writeln(null); } gives: ...\dmd2\src\phobos\std\stdio.d(1562): Error: undefined identifier 'length' ...\dmd2\src\phobos\std\stdio.d(1562): Error: undefined identifier 'ptr', did you mean 'template tr(C1,C2,C3,C4 = immutable(char))'? test.d(3): Error: template instance std.stdio.writeln!(typeof(null)) error instantiating -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 23, 2012 [Issue 7348] to!string(null) matches more than one template declaration | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mariusz Gliwiński | http://d.puremagic.com/issues/show_bug.cgi?id=7348 --- Comment #11 from Kenji Hara <k.hara.pg@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: ------- |
May 23, 2012 [Issue 7348] to!string(null) matches more than one template declaration | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mariusz Gliwiński | http://d.puremagic.com/issues/show_bug.cgi?id=7348 --- Comment #12 from Vladimir Panteleev <thecybershadow@gmail.com> 2012-05-22 20:47:58 PDT --- I agree. I think this behavior is also more useful to the use case in OP's example (logging). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 23, 2012 [Issue 7348] to!string(null) matches more than one template declaration | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mariusz Gliwiński | http://d.puremagic.com/issues/show_bug.cgi?id=7348 --- Comment #13 from Kenji Hara <k.hara.pg@gmail.com> 2012-05-22 21:11:57 PDT --- to!string(null) should be equal to "null": https://github.com/D-Programming-Language/phobos/pull/599 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 28, 2012 [Issue 7348] to!string(null) matches more than one template declaration | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mariusz Gliwiński | http://d.puremagic.com/issues/show_bug.cgi?id=7348 --- Comment #14 from github-bugzilla@puremagic.com 2012-05-28 11:18:06 PDT --- Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/f5ccd7fdab3272e892f4685bab9cbf9e81eda0bd Retry to fix Issue 7348 - Format and unformat typeof(null) objects properly We should represent null literal as "null" instead of "" in formatting, because unformatting requires one or more length string representation of the object. https://github.com/D-Programming-Language/phobos/commit/61947e5fef8d3858dfa9b926e23f9e27517a5ebd Merge pull request #599 from 9rnsr/fix_nullfmt Issue 7348 & 8040 - null literal should be formatted as "null" -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 31, 2012 [Issue 7348] to!string(null) matches more than one template declaration | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mariusz Gliwiński | http://d.puremagic.com/issues/show_bug.cgi?id=7348 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation