digitalmars.D.bugs - [Issue 8040] New: writeln(null) too
- d-bugmail puremagic.com (40/40) May 04 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8040
- d-bugmail puremagic.com (15/15) May 22 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8040
- d-bugmail puremagic.com (9/16) May 23 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8040
- d-bugmail puremagic.com (16/19) May 23 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8040
- d-bugmail puremagic.com (10/23) May 23 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8040
- d-bugmail puremagic.com (6/6) May 29 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8040
- d-bugmail puremagic.com (9/9) May 31 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8040
http://d.puremagic.com/issues/show_bug.cgi?id=8040
Summary: writeln(null) too
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody puremagic.com
ReportedBy: bearophile_hugs eml.cc
Problem found by Ali Çehreli.
D2 code:
import std.stdio: writeln;
class Foo {}
struct Bar {}
void main() {
Foo f = null;
writeln(f);
Bar* b = null;
writeln(b);
writeln(null);
}
Expected output similar to:
cast(Foo)null
cast(Bar*)null
null
DMD 2.056 prints "null" in the first two writeln, and gives errors for the
third one:
...\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(9): 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 04 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8040
Kenji Hara <k.hara.pg gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |pull
https://github.com/D-Programming-Language/phobos/pull/599
With my pull, original code output is:
----
null
null
null
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 22 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8040https://github.com/D-Programming-Language/phobos/pull/599 With my pull, original code output is: ---- null null nullThank you Kenji Hara, this is an improvement. But isn't it better to add types (as in cast(Foo) or cast(Bar*)) to better tell apart the three kinds of null in that example? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 23 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8040But isn't it better to add types (as in cast(Foo) or cast(Bar*)) to better tell apart the three kinds of null in that example?No, it isn't. It is consistent with other literal formatting. writeln(1); // prints "1", not "cast(int)1" writeln(1L); // prints "1", not "cast(long)1" writeln(1f); // prints "1", not "cast(float)1" And, formatting as like cast syntax will make unfomatting complicate. It is less benefit. Furthermore, std.format module does not print value type in general. (Deprecated typedef value was formatted like cast syntax, but I think it is special case) Therefore, I think your proposal has many faults than benefits. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 23 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8040writeln(1); // prints "1", not "cast(int)1" writeln(1L); // prints "1", not "cast(long)1" writeln(1f); // prints "1", not "cast(float)1"In my opinion writeln(1f) and writeln(1.0L) should print 1.0, as in Python:1int(1)1.0float(1)And, formatting as like cast syntax will make unfomatting complicate. It is less benefit. Furthermore, std.format module does not print value type in general. (Deprecated typedef value was formatted like cast syntax, but I think it is special case) Therefore, I think your proposal has many faults than benefits.OK. Thank you for the answers. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 23 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8040 *** Issue 7866 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 29 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8040
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: -------
May 31 2012









d-bugmail puremagic.com 