English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
How to do this properly with OCaml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-07-22 (16:47)
From: brogoff <brogoff@s...>
Subject: Re: [Caml-list] How to do this properly with OCaml?
On Fri, 22 Jul 2005, Berke Durak wrote:
> On Fri, Jul 22, 2005 at 04:26:55PM +0200, Thomas Fischbacher wrote:
> > As one does not have a prototype of such a tuple at the time the array is
> > created, it seems to me as if the best thing one could do in OCaml would
> > be:
> >
> > (1) Make an array of <tuple> option and initially fill it with None.
> >
> > (2) Make an optional array of tuples which is None until the first entry
> > is made.
> I'd suggest you provide a "zero" value for whatever type you want
> to put in your heap.

That's the solution I have used most often. There's usually some out-of-band
value in a computation that works as a zero.

I agree, it's a bit more of a pain in a statically typed language than in Lisp
or Scheme. Nothing to keep you awake at night though.

-- Brian