[mercury-users] .NET Mercury type representation.

Peter Ross pro at missioncriticalit.com
Thu Feb 27 23:58:56 AEDT 2003


Hi Wendelin,

On Thu, Feb 27, 2003 at 11:19:01AM +0200, Wendelin Reich wrote:
> What is definitely not yet stable is the mapping between .NET-types and
> mercury-types. If you use mercury types such as lists and return them to
> calling C#-code, you will discover that their presentation is extremely
> complex and inefficient. To my knowledge, the only composite
> mercury-type which is more-or-less easy to access is the array, because
> it is mapped to CTS-arrays. However, Fergus Henderson told me that the
> representation of other types is not yet stable - if you have to pass
> complex arrays-of-composite-types (say, pairs) between mercury and C#,
> future releases of the compiler might require you to tweak your
> application.
> 
I am interested as to why you find the representation of Mercury types
complex and inefficient.

Here is a quick explanation of the current representation.

:- type t(T)
    --->    f(
                int,
                T
            )
    ;       g(
                int
            ).

This is mapped to the following.

class t_1 {
    int data_tag;   // data_tag can also be used to determine which
                    // data constructor we are using.

        // A nested class representing the f constructor
    class f_2 {
        int     F1;
        object  F2;     // generic types are represented by System.Object
    }

    class g_1 {
        int     F1;
    }
}

I am curious to know how you would choose to represent the above type.
Personally I just wish that .NET choose to make algebraic types directly
representable in the framework.

Pete

--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list