Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2004-04-25 (17:39)
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           its fields;   When a nation ignores the Way,
                            Horses bear soldiers through
                                its streets.
                            --Lao Tzu (Peter Merel, trans.)

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: