[m-rev.] for (possibly post-commit) review: simplify the creation of .int files

Peter Wang novalazy at gmail.com
Tue Feb 19 10:30:15 AEDT 2019


On Mon, 18 Feb 2019 10:31:26 +0000 (UTC), Julien Fischer <jfischer at opturion.com> wrote:
> 
> There are three annotations you can reasonably have concerning
> the size of a foreign_type (in C):
> 
>    1. definitely word sized or less (i.e. can_pass_as_mercury_type).
>    2. definite fixed size, which may exceed the word size.
>    3. definitely greater than a word in size.
> 
> Almost every foreign type I have ever seen falls into the first
> category.
> 
>     :- pragma foreign_type("C", foo, "int64_t").
> 
> is an example of where the second category could be used.
> (At least it was until I added 64-bit integers to the language itself.)
> 
> I don't think I have ever seen an instance of the third category.

I have, where the foreign type is a structure type of a few words.
(It's more convenient to let the compiler do the boxing/unboxing
than reaching for the undocumented GC-malloc macros so I could see a
case for more instances of such foreign types.)

Peter


More information about the reviews mailing list