[m-dev.] bimap

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Jan 8 17:34:45 AEDT 2004


On 08-Jan-2004, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> The first is that bimap__set wasn't ensuring the bijective property.
> If you had a bimap containing 1 <-> "one", and called bimap__set with
> key 1 and value "uno", then the final forward map would be correct, but
> the reverse map would still map "one" as well as "uno" to 1. Does anyone
> have code that depends on the old, incorrect semantics of bimap__set?

I doubt it.

It would be a good idea to actually document the semantics of bimap__set
and the other undocumented procedures in bimap.

> I added a function with signature
> 	bimap__reverse_lookup(bimap(K, V), V) = K
> Do we need a predicate form with this argument order as well,

IMHO no.

> The third is that the bimap exports the concrete implementation of the
> bimap(K, V) type, as well as an abstract declaration. I think this is
> just a mistake, a matter of the :- implementation being a few lines too
> late. Does anyone object to making the type abstract, with two new functions
> to return the forward and reverse maps respectively? Without this, we
> cannot to ensure the bijective property.

An alternative that would be slightly better for backwards compatibility
export bimap/2 as a function (with both forwards and reverse modes),
rather than a constructor, but to then use `pragma obsolete' to deprecate it.
This would require renaming the bimap/2 constructor, e.g to bimap_ctor/2
or mk_bimap/2.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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