[m-dev.] Replacing pairs with 2-tuples
Ralph Becket
rbeck at microsoft.com
Thu Nov 9 03:33:44 AEDT 2000
I was wondering whether it might be wise to consider migrating from
the pair type to 2-tuples by changing to...
:- type pair(T1, T2) == {T1, T2}.
:- func T1 - T2 = pair(T1, T2).
:- mode in - in = out is det.
:- mode out - out = in is det.
X - Y = {X, Y}.
:- func fst(pair(T1, T2)) = T1.
fst(Pair) = X :-
X - _ = Pair.
:- func snd(pair(T1, T2)) = T2.
snd(Pair) = Y :-
_ - Y = Pair.
We could mark -/2 as being deprecated and eventually do away with it
altogether.
The motivation for doing this is
(a) to avoid having two pairing types and
(b) to reduce pollution of the name-space and
(c) to steal back fst/1 and snd/1 for 2-tuples.
Objections? Problems?
--
Ralph Becket | MSR Cambridge | rbeck at microsoft.com
--------------------------------------------------------------------------
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