This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: smob calling (Re: mildly incompatible change)


>>        TO_STRING is used by the printer and must return a string.  All
>>        foreign objects are printed in hash notation.
>
> I prefer the print going to a port actually,
> for big objects is doesn't thrash memory and if you really want a string
> then you can write a `string port' (equivalent to C++ strstream).

Another reason is that if the to_string method knows the destination
port, it can be more intelligent about what it prints.  For example
if the port is doing pretty-printing, the to_string method can
insert appropriate grouping and break markers into the output
stream.  In the port represents a GUI window, perhaps the object
can use an appropriate font or image.  E.g. when displaying a
PNG image object, it could just "print" the image on the window.

	--Per Bothner
Cygnus Solutions     bothner@cygnus.com     http://www.cygnus.com/~bothner