easy way to output a struct?
BCS
ao at pathlink.com
Thu Jan 15 10:54:59 PST 2009
Reply to Hoenir,
> Denis Koroskin schrieb:
>
>> One note is that you should probably pass the object by reference:
>>
>> void log(T)(ref T obj) { ... } // D1
>> void log(T)(ref const(T) obj) { ... } // D2
> Good idea. btw ref'ing a class has no effect, has it?
>
ref object would allow you to alter what the passed in argument is:
void Fn(ref object o) { o = null; }
object o = new Bah!();
Fn(o);
assert(o is null);
> Actually discovered a flaw, if you e.g. pass an array of structs to
> it, dmd complains about the struct not having a toString() member.
>
> So it needs to be recursive somehow.
>
I have a partial solution here: http://www.dsource.org/projects/scrapple/browser/trunk/log_api/LogAPI.d
Feel free to steal whatever you want from it. If you are really adventures
and want to, I can get you SVN access and you can dump stuff back into that.
More information about the Digitalmars-d-learn
mailing list