[m-dev.] comments on binary input streams and bytes as ints

Zoltan Somogyi zoltan.somogyi at runbox.com
Sat Mar 19 04:25:45 AEDT 2022


2022-03-08 21:41 GMT+11:00 "Julien Fischer" <jfischer at opturion.com>:
> Commit 5951724 adds the following XXX comments.
> Here are my comments about those comments.
> 
> +:- instance stream.reader(binary_input_stream,         int,   io,
> io.error).
> +:- instance stream.reader(binary_input_stream,         int8,  io,
> io.error).
> +:- instance stream.reader(binary_input_stream,         uint8, io,
> io.error).
> +% XXX IO_INSTANCE reader for int calls read_byte
> 
> The use of int here is a legacy usage in the standard library.
> Historically, it has represented a "byte" using the lower 8 bits on int.
> 
> Now that we have proper 8 bit sized types, the "byte is the lower 8 bits
> of an int" approach should be deprecated.  (I think I have already added
> uint8/int8 alternatives for all the affected operations.)
> 
> +% XXX IO_INSTANCE inconsistent: no instance for uint
> 
> No such instance should be added.
> 
> +:- instance stream.unboxed_reader(binary_input_stream, int8,  io,
> io.error).
> +:- instance stream.unboxed_reader(binary_input_stream, uint8, io,
> io.error).
> +% XXX IO_INSTANCE no instance for int
> 
> unboxed_readers were added *after* fixed size integers; I didn't think
> there is any point adding an int version only to eventually remove it.
> 
> +:- instance stream.putback(binary_input_stream,        int,   io,
> io.error).
> +:- instance stream.putback(binary_input_stream,        int8,  io,
> io.error).
> +:- instance stream.putback(binary_input_stream,        uint8, io,
> io.error).
> +% XXX IO_INSTANCE putback for int calls putback_byte
> +% XXX IO_INSTANCE inconsistent: no instance for uint
> 
> As above.

I just committed the attached diff to address these comments.

Note that one XXX IO_INSTANCE still remains: why aren't 
int64s and uint64s members of io.stream_writer, despite
io.m having the requisite output predicates? To me, it looks like
an oversight.

Zoltan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DIFF.byte
Type: application/octet-stream
Size: 1661 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/developers/attachments/20220319/25ceab2a/attachment.obj>


More information about the developers mailing list