Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "chris.danx" <chris.danx@ntlworld.com>
To: Richard Jones <rich@annexia.org>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Type problem... possible design problem
Date: Sat, 18 Dec 2004 20:06:51 +0000	[thread overview]
Message-ID: <41C48DDB.4010707@ntlworld.com> (raw)
In-Reply-To: <20041218152759.GA12095@annexia.org>

Richard Jones wrote:
> On Sat, Dec 18, 2004 at 02:28:09PM +0000, chris.danx wrote:
> 
>>My concern with variants is sharing subgraphs in graphs, will they be 
>>shared or copied?
> 
> A tree structure like this should be stored shared:
> 
>   type 'a tree = Leaf of 'a | Node of 'a tree list
> 
> You can prove this; for instance:
> 
> # let n = ref 1;;
> val n : int ref = {contents = 1}
> # let t = Leaf n;;  
> val t : int ref tree = Leaf {contents = 1}
> # let tree = Node [t; t];;
> val tree : int ref tree = Node [Leaf {contents = 1}; Leaf {contents = 1}]
> # n := 2;;
> - : unit = ()
> # tree;;
> - : int ref tree = Node [Leaf {contents = 2}; Leaf {contents = 2}]

Hmm... this looks like it shows two subtrees hold the same reference but 
it does not to me look like it proves the structure is shared, only that 
references work as expected.

Perhaps I can use

type 'a sceneGraph = Leaf of 'a | IntNode of 'a * 'a sceneGraph list | 
SharedNode of 'a sceneGraph ref

to achieve what I want.

Chris


  reply	other threads:[~2004-12-18 20:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-18  0:42 chris.danx
2004-12-18  4:00 ` [Caml-list] " Matt Gushee
2004-12-18  8:07 ` Jon Harrop
2004-12-18 14:28   ` chris.danx
2004-12-18 15:27     ` Richard Jones
2004-12-18 20:06       ` chris.danx [this message]
2004-12-18 18:37     ` Jon Harrop
2004-12-20 11:50     ` skaller

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=41C48DDB.4010707@ntlworld.com \
    --to=chris.danx@ntlworld.com \
    --cc=caml-list@inria.fr \
    --cc=rich@annexia.org \
    /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