digitalmars.D.bugs - [Issue 535] New: writef doesn't work on interfaces
- d-bugmail puremagic.com (35/35) Nov 16 2006 http://d.puremagic.com/issues/show_bug.cgi?id=535
- d-bugmail puremagic.com (7/7) Apr 29 2007 http://d.puremagic.com/issues/show_bug.cgi?id=535
- d-bugmail puremagic.com (10/10) Dec 05 2007 http://d.puremagic.com/issues/show_bug.cgi?id=535
- d-bugmail puremagic.com (13/13) Dec 06 2007 http://d.puremagic.com/issues/show_bug.cgi?id=535
- d-bugmail puremagic.com (8/8) Mar 27 2009 http://d.puremagic.com/issues/show_bug.cgi?id=535
- d-bugmail puremagic.com (10/10) Oct 11 2009 http://d.puremagic.com/issues/show_bug.cgi?id=535
- d-bugmail puremagic.com (11/11) Sep 13 2010 http://d.puremagic.com/issues/show_bug.cgi?id=535
http://d.puremagic.com/issues/show_bug.cgi?id=535
Summary: writef doesn't work on interfaces
Product: D
Version: 0.174
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: bugzilla digitalmars.com
ReportedBy: smjg iname.com
If writef is fed an argument of an interface type, it just throws a
FormatError.
----------
import std.stdio;
interface Qwert {}
class Yuiop : Qwert {
char[] toString() {
return "asdfg";
}
}
void main() {
Qwert hjkl = new Yuiop;
writefln(hjkl);
writefln("%s", hjkl);
}
----------
Error: std.format formatArg
----------
It should use the object's toString property. True, interfaces don't extend
Object and so don't have toString as such, but what could be more sensible than
casting it to an Object and then treating it in the same way?
Adding char[] toString() to the interface makes no difference.
--
Nov 16 2006
http://d.puremagic.com/issues/show_bug.cgi?id=535
thomas-dloop kuehne.cn changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
OS/Version|Windows |All
--
Apr 29 2007
http://d.puremagic.com/issues/show_bug.cgi?id=535
wbaxter gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|enhancement |normal
I'd say this is an outright bug. It can't cast to Object because it could be a
COM interface, but if the interface explicitly has a toString method, then
writef should definitely call it rather than throwing an exception.
--
Dec 05 2007
http://d.puremagic.com/issues/show_bug.cgi?id=535 Surely it's not being a COM _interface_, but being a COM _object_ external to D that would be a problem, right? I suppose the question is whether the runtime can determine if it's a D object. If so, the TypeInfo for interfaces could define this behaviour: If the interface defines a suitable toString, use it. Otherwise, see at runtime whether the interface instance is a D object. If so, convert it to an Object and use its toString, otherwise throw an exception. If this runtime checking isn't possible (or isn't worth the implementation cost), then having a documented requirement that the interface defines a toString for it to work is a possibility, but it still has its drawbacks.... --
Dec 06 2007
http://d.puremagic.com/issues/show_bug.cgi?id=535
dsimcha yahoo.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |2korden gmail.com
*** Bug 2200 has been marked as a duplicate of this bug. ***
--
Mar 27 2009
http://d.puremagic.com/issues/show_bug.cgi?id=535
Andrei Alexandrescu <andrei metalanguage.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
CC| |andrei metalanguage.com
AssignedTo|nobody puremagic.com |andrei metalanguage.com
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 11 2009
http://d.puremagic.com/issues/show_bug.cgi?id=535
Andrei Alexandrescu <andrei metalanguage.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
19:44:38 PDT ---
http://www.dsource.org/projects/phobos/changeset/1996
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 13 2010









d-bugmail puremagic.com 