[m-rev.] io.m latest full diff

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Jan 22 15:54:05 AEDT 2004


On 22-Jan-2004, James Goddard <goddardjames at yahoo.com> wrote:
> > Stripping away all but the lower 8 bits would have two problems:
> 
> Well I thought this approach would be appropriate as this is what is done for
> the .NET mercury_print_binary_string() function as the method for converting
> Unicode strings to byte sequences.

The print_binary_string function is used ONLY for the io__write_bytes
procedure.  io__write_bytes is poorly documented and also arguably
poorly designed, and should perhaps be deprecated and eventually removed.

There are two possible uses for io__write_bytes:
(1) to convert an arbitrary string to a byte sequence.
    This might require using some complicated encoding.
(2) to convert a string containing only 8-bit characters to a byte sequence,
    leaving the byte values completely unchanged.
    In this case, we are really using the string as a packed array of bytes.

Supporting both of these is not possible in general.
The original design didn't make it clear which if any was the original
intent.

> > (1) it would not be possible to read/write terms that use Unicode
> > characters which do not fit into 8 bits
> 
> True, this is a problem.
...
> Why do we even have io__read_binary and io__write_binary if all they do is
> call the equivalent text predicates anyway?

It's partly a hook to allow programs written now to take advantage of
more sophisticated implementations of io__read_binary/write_binary
written later.

But it is also needed because the equivalent text predicates can only
write to text files, but users may want to write arbitrary terms to
binary files (mixed in amongst their other binary data).

> If you like I could have a go at
> changing them so that they use binary methods instead.

Doing that properly is a non-trivial task -- more than a week's work,
I'd say.  So no, don't do that now.  Other aspects of the Java back-end
are more important.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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