From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id A89E2BB81 for ; Fri, 22 Jul 2005 18:47:58 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j6MGlwXL007427 for ; Fri, 22 Jul 2005 18:47:58 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA32749 for ; Fri, 22 Jul 2005 18:47:57 +0200 (MET DST) Received: from mail22.sea5.speakeasy.net (mail22.sea5.speakeasy.net [69.17.117.24]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j6MGltU8007412 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 22 Jul 2005 18:47:56 +0200 Received: (qmail 16447 invoked from network); 22 Jul 2005 16:47:52 -0000 Received: from shell1.sea5.speakeasy.net ([69.17.116.2]) (envelope-sender ) by mail22.sea5.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 22 Jul 2005 16:47:52 -0000 Date: Fri, 22 Jul 2005 09:47:52 -0700 (PDT) From: brogoff X-X-Sender: brogoff@shell1.sea5.speakeasy.net To: Berke Durak Cc: Thomas Fischbacher , caml-list@inria.fr Subject: Re: [Caml-list] How to do this properly with OCaml? In-Reply-To: <20050722155008.GA11661@ara.zapto.org> Message-ID: References: <20050722155008.GA11661@ara.zapto.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at concorde with ID 42E1233E.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 42E1233B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 berke:01 durak:01 ocaml:01 heap:01 statically:01 2005,:98 awake:98 wrote:01 wrote:01 tuples:01 computation:01 speakeasy:01 lisp:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 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 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