[mercury-users] Support for C# generics in polymorphic types?

Jeff Thompson jeff at thefirst.org
Thu Jan 26 15:15:56 AEDT 2012


Hello again on yet another thread.  The Mercury polymorphic type definition:
:- type foo(T) ---> foo(int, T).
is converted to the C# code:
   public class Foo_1
   {
       public int F1;
       public object F2;

       public Foo_1(int F1, object F2)
       {
           this.F1 = F1;
           this.F2 = F2;
       }
   }

This requires to convert to and from object and requires extra run time 
type checking.  Are there any plans for the compiler to use C# generics 
like the following?
   public class Foo_1<T>
   {
       public int F1;
       public T F2;

       public Foo_1(int F1, T F2)
       {
           this.F1 = F1;
           this.F2 = F2;
       }
   }

In the mean time I find myself avoiding polymorphic types since I need 
the greatest speed.

Thanks for all the illuminating help,
- Jeff

--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list