[Prev][Next][Index][Thread]

Re: Extending format strings.



"Michael T. Richter" <mtr@ottawa.com> writes:

> 1) Is this correct?  Do I have to use %S and a custom method
> dispatched by type?  Is there any way to add new formatting
> characters to the control string so I can use the more familiar %f
> et al suite?

I've never done it some I'm not sure. Overriding print-message and
using %S seems like it might work though. You could also use the
'xformat' library available in the Gwydion Dylan contributions area
which is a Dylan version of Lisp's FORMAT - this has many more
features than the Dylan format.

> 2) How do I add print-message methods when it looks like
> print-message is sealed?

In Functional Developer betas, print-message was sealed. I raised this
as a bug and I'm pretty sure they fixed this in the release. Are you
using FD 2.0?

> 3) What is the footprint of print-message anyway?  The docs say that
> print-message has two arguments but don't actually provide the order of
> arguments, etc. in any clear fashion.

define method print-message( c :: <my-object>, s :: <stream>) => ()
  write(s, "Something about my object);
end;

> 4) Another candidate seems to be to use %= and print-object instead.
> Is this correct or is print-object used for something completely
> different?

I have a custom <money> class and to print it I specialize
print-object and use %= in format to print it. So maybe this is an
approach. Not sure if you specialize print-object for the float
classes though as they might already be specialized and sealed.

Chris.
-- 
http://www.double.co.nz/dylan





Follow-Ups: References: