[m-rev.] Converting univ values to strings

Ralph Becket rafe at cs.mu.OZ.AU
Fri Jul 18 15:18:53 AEST 2003


Simon Taylor, Thursday, 17 July 2003:
> 
> I'm not sure that this is a good idea. The performance of this approach
> will really suck for large data structures. The double maintenance
> problem will go away if/when we implement string streams.

I'm not sure it's that bad.  The string representation will almost
certainly be smaller than the term represented and will be junk straight
after it's output.  Just how often do we print out huge terms anyway?
The pretty printer can handle giant terms economically if this is an
issue.  I think it's a Very Bad Thing when you can print something, but
you can't turn it into a string...

One could, if desperate, parameterise the implementation so that rather
than just collecting a list of strings

value_to_revstrings(Value, ..., !R) :-
	...
	add_revstring(String, !R),
	...

where

add_revstring(S, Rs, [S | Rs]).

it used some higher order arrangement

format_value(Value, ..., P, !R) :-
	...
	P(String, !R),
	...

and we pass in
- add_revstring and revstrings for P and !R for the convert-to-string
  functionality or
- io.write_string and io.state for P and !R for the write-as-string
  functionality.

But, as I say, my feeling is that the solution as posted is fine.

-- Ralph
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list