From: "Coscoy, Yann" <yann.coscoy@icdc.caissedesdepots.fr>
To: caml-list@inria.fr
Subject: RE: hashtables for mutable records
Date: Fri, 28 Apr 2000 10:14:48 +0200 [thread overview]
Message-ID: <40C4228EC468D211B04800A0C9DF1D6636DE0E@tsexchange.idt.cdc.fr> (raw)
Hello,
Pierre Weis wrote :
> You can use a unique integer field into your records
It is the solution I use. But, I dislike it because it makes necessary to
embed the record in some abstract type. (You must hide the constructor of
the recors to guaranty the uniqueness of the integer.)
> Of course you must use your own hashing function that just reads this
fixed integer field.
I can do that, but it make impossible to use Hashtbl.Make because of the
poymorphism of the record.
> As of polymorphism, if your problem is just to have keys or values
> belonging to a parameterized data type, you can directly use the
> creation and manipulation functions from the Hashtbl module
> (Hashtbl.create, Hashtbl.add, etc): they accept to manipulate
> polymorphic tables. Since usage of these functions with a user defined
> hash function is not available from the Hashtbl module, you should
> rewrite some parts of its code into your own hash table module.
I know I can solve my problem in this way. But I don't think that "cut,
paste, and patch the stdlib" is a good practice. So, I prefer to use the
integer itself as the key of hashtable and use the standard Hash module.
I partial solution would be to have another functor Make1 in module Hashtbl
with type 'a key. (It is just a partial solution, because it doesn't solve
the problem for type ('a, 'b) key and type ('a, 'b, 'c) key.)
Yann coscoy
PS: the signature of this Make1 functor:
module type HashedType1 =
sig
type 'a t
val equal: 'a t -> 'a t -> bool
val hash: 'a t -> int
end
module type S1 =
sig
type 'a key
type ('a, 'b) t
val create: int -> ('a, 'b) t
val clear: ('a, 'b) t -> unit
val add: ('a, 'b) t -> 'a key -> 'b -> unit
val remove: ('a, 'b) t -> 'a key -> unit
.....
next reply other threads:[~2000-04-28 10:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-04-28 8:14 Coscoy, Yann [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-04-27 13:28 Coscoy, Yann
2000-04-27 17:56 ` Pierre Weis
2000-04-28 1:12 ` Jacques Garrigue
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=40C4228EC468D211B04800A0C9DF1D6636DE0E@tsexchange.idt.cdc.fr \
--to=yann.coscoy@icdc.caissedesdepots.fr \
--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