[m-rev.] Converting univ values to strings

Ralph Becket rafe at cs.mu.OZ.AU
Wed Jul 16 17:13:06 AEST 2003


Fergus Henderson, Wednesday, 16 July 2003:
> On 16-Jul-2003, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> > Index: library/io.m
> ...
> > @@ -2882,48 +2600,41 @@
> >  :- mode io__write_type_desc(in, di, uo) is det.
> >  
> >  io__write_type_desc(TypeDesc) -->
> > -	io__write_string(type_name(TypeDesc)).
> > +	io__get_op_table(OpsTable),
> > +	{ univ_to_string(canonicalize, OpsTable, univ(TypeDesc), String) },
> > +	io__write_string(String).
> >  
> > [...]
> 
> I think all of those procedures are now dead, aren't they?
> Can't all that code be just deleted?

Done.

> ...
> > +:- func string__string(T) = string.
> > +%	string__string(Value)
> > +%		Converts an arbitrary value to a canonicalized string
> > +%		representation using the standard Mercury operator
> > +%		table.
> 
> Hmm... for the variants with >= 2 arguments, wouldn't it be more natural
> for the user if the interface used `T', like string__string/1, rather than
> `univ', like univ_to_string/1?
> 
> Also, why provide both univ_to_string/1 and string__string/1?
> If we provided only string__string/1, a user who wants
> univ_to_string(Univ) can call string(univ_value(Univ)).
> It doesn't seem worth complicating the library interface by
> providing both of them.

I agree.  Where should the code go?  Stuff that works on arbitrary terms
has a std_util.m flavour to it, but the natural name for it, string/...,
suggests it should live in string.m.  That said, we already have
pprint.to_doc and that's not in std_util.

Any opinions?

-- 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