Browse thread
References, compact bollean values (and other questions)
-
Seth J. Fogarty
-
Brian Hurt
- skaller
-
Brian Hurt
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2005-11-04 (02:39) |
From: | skaller <skaller@u...> |
Subject: | Re: [Caml-list] References, compact bollean values (and other questions) |
On Thu, 2005-11-03 at 18:20 -0600, Brian Hurt wrote: > > On Thu, 3 Nov 2005, Seth J. Fogarty wrote: > > > First question: I notice references are implemented using mutable > > records. Does this imply tuples of references are slower than mutable > > records? > > I.E. > > type a = int ref * int ref * int ref > > vs > > type a = {mutable a : int; mutable b : int; mutable c : int} > > The mutable structure will almost certainly be less memory and faster. > The tuple of structures will be a tuple of three pointers to three > different mutable integers. The structure will simply be three integers, > stored unboxed in the structure. Yes but note it depends what you are doing. A field is NOT a first class value. A reference is. So if you use functional update to rebuild a record, you are not tickling the write barrier -- true even if a field is a reference. So it depends what you are doing with these records, IMHO. -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net