[m-rev.] for review: C foreign types

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Mar 19 14:13:16 AEDT 2002


On 18-Mar-2002, Peter Ross <peter.ross at miscrit.be> wrote:
> On Mon, Mar 11, 2002 at 10:59:45PM +1100, Fergus Henderson wrote:
> > On 05-Mar-2002, Peter Ross <peter.ross at miscrit.be> wrote:
> > > 
> > > +++ doc/reference_manual.texi	5 Mar 2002 12:05:48 -0000
> > > +The C @samp{pragma foreign_type} declaration is of the form:
> > > +
> > > + at example
> > > +:- pragma foreign_type(c, @var{MercuryTypeName}, @var{CForeignType}).
> > > + at end example
> > > +
> > > +The @var{CForeignType} can be any C type name that obeys the following
> > > +restrictions.
> > > +The type must fit into a machine word.
> > 
> > The notion "machine word" is not defined.
>
> I have changed it to sizeof(CForeignType) == sizeof(char *).

Use `void *' rather than `char *' as the generic pointer type.

This restriction alone is not sufficient, e.g. it still won't work
correctly for floating point types or structs that happen to have the
right size.

> > Function types and incomplete types should not be allowed.
> > 
> > Array types should probably not be allowed (due to their
> > non-orthogonal semantics for parameter-passing etc. in C).
> > 
> > Enum types, struct types, and floating point types should ideally be allowed,
> > but your implementation only works for integer types and pointer types.
> > 
> It would be ideal if it also worked on the above types.
> Currently I do not have the time to implement the boxing and unboxing of
> values automatically.
> Personally I think it would be a great thing to have, as it would allow
> us (once we could specify a user-defined comparison) to move the builtin
> types out of the compiler and into the library.
> So for the moment, I believe, that forcing the user to do there own
> boxing and unboxing is a sufficient amount of functionality for most
> peoples uses.
> Does that sound find to you?

Well, I guess it's better than a kick in the teeth ;-)

In the long run I think we should support all types,
but it's OK to implement a subset of the planned interface.
Just make sure you carefully document what is / is not implemented.

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