caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Damien Doligez <damien.doligez@inria.fr>
To: Pietro Abate <Pietro.Abate@anu.edu.au>
Cc: ocaml ml <caml-list@inria.fr>
Subject: Re: [Caml-list] sharing problem ...
Date: Mon, 26 Jan 2004 14:27:46 +0100	[thread overview]
Message-ID: <6DCE648A-5003-11D8-8717-00039310CAE8@inria.fr> (raw)
In-Reply-To: <20040126104345.GA3978@pulp.anu.edu.au>

On Monday, January 26, 2004, at 11:43 AM, Pietro Abate wrote:

> I'm trying to implement a (string * set) hashtbl
> where some element (set) should be shared between different
> objects.
> the main point is that when I clone an object I want to duplicate
> some sets and shared others (sticky sets)

This doesn't make sense because your set type is built from the
standard library's Set module.  Thus your sets are purely applicative:
you cannot modify them with side-effects.

Shared or not, the elements of a1 will not change when you change
the elements of a2, because changing the elements of a2 doesn't
change the elements themselves, it only replaces them with new
elements (which are not shared, by definition).

That can be seen in your code:

                 sets <- MyMap.remove name sets;
                 sets <- MyMap.add name (set',t) sets

You don't change the shared set, you remove it from the map and then
add a new one under the same name.

If you really need mutable sets, maybe you should use the Hashtbl
module instead of Set.

-- Damien

-------------------
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


  parent reply	other threads:[~2004-01-26 13:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-26 10:43 Pietro Abate
2004-01-26 11:22 ` Nicolas Cannasse
2004-01-26 13:27 ` Damien Doligez [this message]
2004-01-26 13:46   ` Pietro Abate

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=6DCE648A-5003-11D8-8717-00039310CAE8@inria.fr \
    --to=damien.doligez@inria.fr \
    --cc=Pietro.Abate@anu.edu.au \
    --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;
as well as URLs for NNTP newsgroup(s).