[mercury-users] .NET Mercury type representation.
Richard A. O'Keefe
ok at cs.otago.ac.nz
Fri Feb 28 11:26:12 AEDT 2003
Peter Ross <pro at missioncriticalit.com> said
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.
I am not familiar with C#. Here's how I would do it in Java.
abstract class T { abstract int tag(); }
class T_F extends T { int tag() { return 0; } int x1; object x2; }
class T_G extends T { int tag() { return 1; } int x2; }
Personally I just wish that .NET choose to make algebraic types
directly representable in the framework.
The mapping of algebraic types onto Java shown above is pretty direct:
a class for each type with a subclass for each constructor. If there
is only one constructor, the "type" and "constructor" classes fuse and
there is no tag() method.
No wasted space. The Java tag represents the Mercury tag.
Isn't such a mapping possible for C#?
--------------------------------------------------------------------------
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