[m-rev.] for review: io.primitives_{read,write}.m

Zoltan Somogyi zoltan.somogyi at runbox.com
Sat Mar 12 14:53:00 AEDT 2022


2022-03-12 14:35 GMT+11:00 "Julien Fischer" <jfischer at opturion.com>:
>> --- a/library/io.primitives_read.m
>> +++ b/library/io.primitives_read.m
>> @@ -0,0 +1,871 @@
>> +%---------------------------------------------------------------------------%
>> +% vim: ft=mercury ts=4 sw=4 et
>> +%---------------------------------------------------------------------------%
>> +% Copyright (C) 1993-2012 The University of Melbourne.
>> +% Copyright (C) 2013-2022 The Mercury team.
>> +% This file is distributed under the terms specified in COPYING.LIB.
>> +%---------------------------------------------------------------------------%
>> +%
>> +% File: io.primitives_read.m.
>> +%
>> +% This file handles the details of reading in values of primitive types.
>> +%
>> +% We communicate results from foreign_procs as separate simple arguments
>> +% so the C/Java/etc code does not depend on how Mercury stores its
>> +% discriminated union data types. It also avoids memory allocation in
>> +% inner loops.
>> +%
>> +%---------------------------------------------------------------------------%
>> +%---------------------------------------------------------------------------%
>> +
>> +:- module io.primitives_read.
>> +:- interface.
>> +
>> +:- import_module char.
>> +
>> +    % We communicate results from foreign_procs as separate simple arguments
>> +    % so the C/Java/etc code does not depend on how Mercury stores its
>> +    % discriminated union data types. It also avoids memory allocation in
>> +    % inner loops.
> 
> That comment just repeats the one in the head of the file.

Duplicate copy deleted.

>> +%---------------------------------------------------------------------------%
>> +:- implementation.
>> +%---------------------------------------------------------------------------%
> 
> This code is lacking a C foreign_decl that #includes stdint.h, inttypes.h
> mercury_int.h.  (Conversely, those headers may not be #included in io.m's
> C foreign_decl block.)

Even io.m did not directly #include stdint.h; it got it indirectly via
mercury_int.h.

I added #includes of mercury_types.h, mercury_int.h and inttypes.h
to make the code self-contained, though this file gets them anyway through
io.m.

If, by the last bit, you mean that those #includes could be deleted
from io.m as unneeded, I would prefer to do that once, when this
batch of changes to io.m is done.

> As a generaly point, I would fully qualify things in Java and C# foreign_procs.

Good idea. Problem is, I do not know what the fully qualified names are :-(
Care to educate me on that?

>> +
>> +:- implementation.
>> +
>> +% ZZZ :- import_module array.
>> +
>> +% ZZZ :- pragma foreign_import_module("C#", array).
> 
> Why are those there?

Deleted.

> Again, there is a lack of #includes for stdint.h, inttypes.h etc here.

Same set of #includes added as for reads.

Thanks.

Zoltan.


More information about the reviews mailing list