digitalmars.D.bugs - [Issue 691] New: Object.print ought to be removed or at least deprecated
- d-bugmail puremagic.com (37/37) Dec 16 2006 http://d.puremagic.com/issues/show_bug.cgi?id=691
- d-bugmail puremagic.com (5/5) Apr 29 2007 http://d.puremagic.com/issues/show_bug.cgi?id=691
- d-bugmail puremagic.com (10/10) Dec 08 2008 http://d.puremagic.com/issues/show_bug.cgi?id=691
http://d.puremagic.com/issues/show_bug.cgi?id=691 Summary: Object.print ought to be removed or at least deprecated Product: D Version: 0.177 Platform: All URL: http://www.digitalmars.com/d/archives/digitalmars/D/2558 6.html OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Phobos AssignedTo: bugzilla digitalmars.com ReportedBy: smjg iname.com The Object class contains the method void print(); Its flaw is that it gives the application using it no choice of what to output to. Different applications, or even parts of the same application, may want to output variously to stdout, stderr, a log file or a GUI window, just to name a few possibilities. And it serves no real purpose. If a program wants to output the string representation of something, it can use .toString directly, which is much more versatile. While in theory print could be overridden e.g. to show more information than would appear in the toString, this isn't the way to do it. Better would be for individual classes that want to do this to define a function such as toLongString. A class designer may also want to have the information output piece by piece to avoid having to allocate enough memory to hold the whole output at once - again, such a class would define its own print function. Preferably one that takes an OutputStream parameter rather than having the destination hard-coded as with the current Object.print. I therefore agree with the proposals of various people that it should be got rid of. Partly because of its lack of practical use, but mainly because of its flaw. It should at least be deprecated ASAP. Removing it altogether would require a recompile, but at least if this is done before 1.0 then it would save having to recompile later. --
Dec 16 2006
http://d.puremagic.com/issues/show_bug.cgi?id=691 Why does this depend on issue 341? If we're going to get rid of it, we don't want to document it, do we? --
Apr 29 2007
http://d.puremagic.com/issues/show_bug.cgi?id=691 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED This has been removed from D 2.0. It won't be removed D 1.0 because of backwards compatibility issues. --
Dec 08 2008