Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] help
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Matt Gushee <mgushee@h...>
Subject: Re: [Caml-list] help
On Sun, Apr 25, 2004 at 06:06:23PM +0100, Jon Harrop wrote:
> On Sunday 25 April 2004 5:30 pm, mohammad siddiqui wrote:
> > I tried exactly what you have told. Its is fine when we just have one
> > element in an array of words. If we have more than one, changing the value
> > of one changes the values of the rest of the elements.
> 
> Sorry, yes. Now I come to think of it, it's kind of obvious that a mutable 
> field in a record would also get copied.

Yes, a mutable field *or* a ref (which invalidates one of the solutions
I suggested). Actually, a ref is just a predefined record type that has a 
mutable field and is supported with a special assignment operator.

  # let wnum = { contents = 0 };;
  val wnum : int ref = {contents = 0}

-- 
Matt Gushee                 When a nation follows the Way,
Englewood, Colorado, USA    Horses bear manure through
mgushee@havenrock.com           its fields;
http://www.havenrock.com/   When a nation ignores the Way,
                            Horses bear soldiers through
                                its streets.
                                
                            --Lao Tzu (Peter Merel, trans.)

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