Browse thread
How to do this properly with OCaml?
-
Thomas Fischbacher
- Christophe Dehlinger
- Berke Durak
- Michel Quercia
- Eric Cooper
-
Michael Alexander Hamburg
-
Xavier Leroy
- Berke Durak
- Michael Alexander Hamburg
- Thomas Fischbacher
- Alex Baretta
- skaller
- Thomas Fischbacher
-
Xavier Leroy
[
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: | -- (:) |
| From: | james woodyatt <jhw@w...> |
| Subject: | Re: [Caml-list] How to do this properly with OCaml? |
On 23 Jul 2005, at 13:15, Brian Hurt wrote:
> On Sat, 23 Jul 2005, Thomas Fischbacher wrote:
>>
>> If I duplicate entries to fill up holes, and later on remove a
>> legitimate entry whose duplicates fill holes from the heap, I have
>> to introduce extra bookkeeping so that the other placeholder
>> copies of that entry are replaced as well - otherwise it could not
>> be reclaimed by GC.
>
> I'd be very inclined just to use options- especially since, as
> you've mentioned in other posts, the elements you're putting into
> the heap are are fairly large and expensive to create. In this
> case, the overhead of options is small, relative to the rest of the
> data.
If they're large and expensive to create, I'd consider using ['a
Lazy.t array] instead of ['a array]. When you initialize the array,
do it like this:
let initArray n = Array.init n (fun _ -> lazy (assert false))
--
j h woodyatt <jhw@wetware.com>
markets are only free to the people who own them.