Bug 13680 – Better printing of class instances that don't have a toString

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2014-11-04T10:45:58Z
Last change time
2024-12-01T16:22:51Z
Assigned to
No Owner
Creator
bearophile_hugs
See also
https://issues.dlang.org/show_bug.cgi?id=3248
Moved to GitHub: phobos#10095 →

Comments

Comment #0 by bearophile_hugs — 2014-11-04T10:45:58Z
This program shows the current default printing of class instances (dmd 2.067alpha): class Foo {} void main() { import std.stdio; Foo f; f.writeln; f = new Foo; writeln(f, " ", cast(void*)f); } Output: null test.Foo 2001FE0 But perhaps it's better for D writeln to print class instances (that don't have a toString) more like Java: test.Foo@null test.Foo@2001FE0 2001FE0 This is useful in debugging and code development, because the address allows to see what class instances are equal.
Comment #1 by robert.schadek — 2024-12-01T16:22:51Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10095 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB