www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - writef(Object) just writes a random number

reply Stewart Gordon <smjg_1998 yahoo.com> writes:
Using DMD 0.95, Windows 98SE.

According to std_format.html, for the %s format

classes derived from Object
	The result is the string returned from the class instance's .toString() 
method. A Precision specifies the maximum number of characters to use in 
the result.


I see you haven't tested this yet.  Well I have, and it's just throwing 
random numbers at me:

18314152873893856
4301856736


Stewart.

----------
import std.stdio;

class Qwert {
	char[] toString() {
		return "yuiop";
	}
}

void main() {
	Qwert asdfg = new Qwert;

	writefln(asdfg);
	writefln("%s", asdfg);
}

-- 
My e-mail is valid but not my primary mailbox, aside from its being the 
unfortunate victim of intensive mail-bombing at the moment.  Please keep 
replies on the 'group where everyone may benefit.
Jul 12 2004
parent Ant <Ant_member pathlink.com> writes:
In article <cctog6$18bq$4 digitaldaemon.com>, Stewart Gordon says...
Using DMD 0.95, Windows 98SE.

According to std_format.html, for the %s format

classes derived from Object
	The result is the string returned from the class instance's .toString() 
method. A Precision specifies the maximum number of characters to use in 
the result.


I see you haven't tested this yet.  Well I have, and it's just throwing 
random numbers at me:

18314152873893856
4301856736
it's probably the same as http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/770 Ant
Jul 12 2004