From: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@lri.fr>
To: Alex Baretta <alex@baretta.com>
Cc: ocaml <caml-list@inria.fr>
Subject: Re: [Caml-list] Map efficiency?
Date: Fri, 7 Nov 2003 09:27:19 +0100 [thread overview]
Message-ID: <16299.22375.433305.104788@gargle.gargle.HOWL> (raw)
In-Reply-To: <3FA7EC77.50502@baretta.com>
Alex Baretta writes:
> > Map depends on keys to be ordered. This in turn requires to allow for a
> > user-defined order: assume sets as keys that are implemented by
> > unordered lists. Different lists can represent the same set. Hence, it
> > must be possible to provide a user-defined order that would treat those
> > lists as equal. The functor argument of Map contains the compare() which
> > does just that.
>
> The order function could just as easily be passed as a parameter to all
> functions working on the map.
This is not a good idea, because elements could be inserted using one
ordering function and looked for using a different one, with tragic
consequences.
A slightly better approach would be to pass the ordering function to
Map.empty only, which would store it inside the data structure. This
is exactly what was done in Caml Light, when Caml did not have a
module system yet.
(see http://camlcvs.inria.fr/cgi-bin/cvsweb.cgi/camllight/src/lib/map.mli?rev=1.3&content-type=text/x-cvsweb-markup)
(But the functorial interface is definitely the best, of course.)
--
Jean-Christophe Filliâtre
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2003-11-07 8:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-04 7:59 Dustin Sallings
2003-11-04 9:11 ` Jean-Christophe Filliatre
2003-11-04 10:00 ` Richard Jones
2003-11-04 19:58 ` Issac Trotts
2003-11-04 9:39 ` Christian Lindig
2003-11-04 18:14 ` Alex Baretta
2003-11-05 1:09 ` Nicolas Cannasse
2003-11-07 8:27 ` Jean-Christophe Filliatre [this message]
2003-11-07 11:39 ` Why are functors better? (Re: [Caml-list] Map efficiency?) Yaron M. Minsky
2003-11-07 14:02 ` Michael Hicks
2003-11-07 14:08 ` Fernando Alegre
2003-11-07 14:49 ` [Caml-list] Map efficiency? Florian Hars
2003-11-04 19:37 ` Dustin Sallings
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=16299.22375.433305.104788@gargle.gargle.HOWL \
--to=jean-christophe.filliatre@lri.fr \
--cc=alex@baretta.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox