[mercury-users] [Feature request] Printing reasonable floats/printer pred

Julien Fischer juliensf at csse.unimelb.edu.au
Mon Feb 12 12:34:49 AEDT 2007


On Sun, 11 Feb 2007 doug.auclair at logicaltypes.com wrote:

> Dear all, I wrote and Julian responded:
>
>>> Is it possible to set some value in the io state to control how
>>> float is printed?
>> Nobody has responded, so: AFAICT, no.  My quick research showed
>> that: [snip]
>
> Therefore I have a feature request, which is that the precision of
> floats be part of io.state accessable to the user, so that write/[3,4]
> prints a float based on this value.

write/{3,4} are based on stream.string_writer.write which doesn't
(necessarily) have access to the I/O state.

I think a better solution would be to pass an additional argument
to write that specifies things like how floats should be formatted.
(The default settings for this argument would correspond to the
existing behaviour for write/{3,4}).

> Or, if you wish to go all the way (which I find desireable), then io.state
> should have a printer predicate slot that for any type T write/[3,4]
> prints T in the format specificed by the particular clause associated
> with that type (defaulting to what write does if this predicate fails).

Again in the context of generalised streams attaching this information
to the I/O state is the wrong thing to do IMO.

Julien.
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list