[m-dev.] `pragma export' C calling convention & polymorphism

Tyson Dowd trd at cs.mu.OZ.AU
Thu Nov 2 23:56:22 AEDT 2000


On 02-Nov-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> Hi,
> 
> What type should `pragma export' use for polymorphically typed
> arguments -- `MR_Word' or `MR_Box'?  Currently it is schitzophrenic.
> The reference manual says
> 
>  | 	Mercury variables of type `int', `float', `char', or `string'
>  | 	are passed to and from C as C variables whose type is given by
>  | 	the corresponding typedef.  Mercury variables of any other
>  | 	type are passed as a `MR_Word'
> 
> but the compiler uses `MR_Box'.  This only makes a difference for
> MLDS grades -- for LLDS grades, `MR_Box' is just a typedef for `MR_Word',
> but for MLDS grades `MR_Box' is `void *', while `MR_Word' is an
> unsigned integer type.
> 
> At some point we probably want to change the conventions used by
> `pragma export' dramatically, to be something very similar to those
> used by the current --high-level-data MLDS back-end.  But I don't want
> to do that now.
> 
> So I guess for now the best solution is to go with what the reference
> manual says, and treat the compiler's current behaviour as a bug?

It's certainly the least work.

I personally think that MR_Box is a much better type for polymorphic
types (and c_pointer types).  

This makes a big difference for the IL backend because I actually have
to create a single element array for MR_Word (and this is after I box
the value).

But when I looked at fixing it for c_pointers, I ran into problems with
abstract types.  If a c_pointer was defined as an abstract type, it
looks like an MR_Word in the interface, but a MR_Box in the
implementation.

-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't everyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list