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

James Goddard goddardjames at yahoo.com
Thu Jan 22 14:28:16 AEDT 2004


 --- Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > I think that io__write_binary will actually succeed..
> 
> Well, having io__write_binary succeed is not much help if
> the result can't be read in with io__read_binary.

But if read_binary is implemented symmetrically you should get the same thing
out that you put in in the majority of cases. (Except with horrible Unicode
stuff)
 
> 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.

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

> (2) even for those that do fit into 8 bits, the encoding of those
> characters might be different than the platform's native encoding
> for "char", so the resulting binary files would not necessarily be
> interoperable with Mercury code compiled for the C back-end.

We already have this caveat anyway: (from declaration of io__read_binary)
%               Note: if you attempt to read a binary representation written
%               by a different program, or a different version of the same
%               program, then the results are not guaranteed to be meaningful.

> 
> > I could merge read_char() and read_byte() into a single read() function, so
> > that you could actually call read_char_code on binary streams, (and
> > read_byte_val on text streams) and it would behave in a symmetrical manner.
> 
> > Would this be appropriate and/or solve the problem?
> 
> I'm not sure.

Well, I'm not saying my idea is the perfect solution, just that it would be
*less* bad than what I have at the moment =)

Why do we even have io__read_binary and io__write_binary if all they do is call
the equivalent text predicates anyway?  If you like I could have a go at
changing them so that they use binary methods instead.

http://personals.yahoo.com.au - Yahoo! Personals
New people, new possibilities. FREE for a limited time.
--------------------------------------------------------------------------
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