CoupleType: Category == with { construct: (Integer, Integer) -> %; equal: (%, %) -> Integer; print: (%) -> (); } Couple: CoupleType == add { attrib(left: Integer, right: Integer); construct(l: Integer, r: Integer): % == attrib(l, r); equal(x: %, y: %): Integer == { if (x.left = y.left) and (x.right = y.right) then {return 2; } else {return 0; } } print(x: %): () == { print(x.left); print(x.right); } } Pair: CoupleType == Couple add { attrib(); construct(l: Integer, r: Integer): % == if (l = r) then error else attrib(l, r); equal(x: %, y: %): Integer == { if ((x.left = y.left) and (x.right = y.right) or (x.left = y.right) and (x.right = y.left)) then {return (2); } else {return (0);} } } main():() == { p: Couple := construct(1,2); print(p); q: Pair := construct(2,1); print(p); } main();A possible translation to C would be
struct Couple { int left; int right; }; struct Couple *construct_Couple(int l, int r) { struct Couple *tmp_Couple = (struct Couple *) malloc(sizeof(struct Couple)); (tmp_Couple) -> left = l; (tmp_Couple) -> right = r; return (tmp_Couple); }; int equal_Couple(struct Couple *tmp1_Couple, struct Couple *tmp2_Couple) { if (((tmp1_Couple) -> left == (tmp1_Couple) -> left) && ((tmp1_Couple) -> right == (tmp1_Couple) -> right)) { return (2); } else { return (1); } } int print_Couple(struct Couple *tmp_Couple) { int tmp_int_0 = 0; printf("%d \n", (tmp_Couple) -> left ); printf("%d \n", (tmp_Couple) -> right); return (tmp_int_0); }; struct Pair { int left; int right; }; struct Pair *construct_Pair(int l, int r) { struct Pair *tmp_Pair = (struct Pair *) malloc(sizeof(struct Pair)); if (l == r) { exit(1); } else { (tmp_Pair) -> left = l; (tmp_Pair) -> right = r; return (tmp_Pair); } }; int equal_Pair(struct Pair *tmp1_Pair, struct Pair *tmp2_Pair) { if ((((tmp1_Pair) -> left == (tmp2_Pair) -> left) && ((tmp1_Pair) -> right == (tmp2_Pair) -> right)) || (((tmp1_Pair) -> left == (tmp2_Pair) -> right) && ((tmp1_Pair) -> right == (tmp2_Pair) -> left))) { return (2); } else { return (0); } } int print_Pair(struct Pair *tmp_Pair) { return (print_Couple((struct Couple *) tmp_Pair)); }; int main() { int tmp_int_1 = 1; int tmp_int_2 = 2; int tmp_int_3 = 2; int tmp_int_4 = 1; struct Couple *p = construct_Couple(tmp_int_1, tmp_int_2); struct Pair *q = construct_Pair(tmp_int_3, tmp_int_4); print_Couple(p); print_Pair(q); return 0; };