From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA31100; Tue, 19 Jun 2001 09:25:37 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA31071 for caml-list@pauillac.inria.fr; Tue, 19 Jun 2001 09:25:37 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA21123 for ; Mon, 18 Jun 2001 16:49:22 +0200 (MET DST) Received: from adsl-gw.nexgen-private (ABoulogne-102-1-2-208.abo.wanadoo.fr [193.251.35.208]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f5IEnL128935 for ; Mon, 18 Jun 2001 16:49:22 +0200 (MET DST) Received: from fabien (fabien.nexgen-private [192.9.200.110]) by adsl-gw.nexgen-private (8.10.2/8.10.2) with SMTP id f5IEZOJ15202; Mon, 18 Jun 2001 16:35:24 +0200 Message-ID: <006d01c0f806$3eea0430$6ec809c0@fabien> From: "FabienFleutot" To: , "David Fox" Cc: "caml" References: <20010616170909.B10922@jean> Subject: Re: [Caml-list] Newbie: declarations Date: Mon, 18 Jun 2001 16:52:06 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: "David Fox" > leary@nwlink.com writes: > > > Is there a way to declare a variable and not initialize it, like C? > > > > int i; > > i = 0; > > > > More to the point, is there a way to declare a record variable without > > listing/initializing all the fields? If yes, what are the default values? > [...] > My first pass solution is to create a reference > to a dummy object: > > let dummy = {field1=0; field2=0...} > let current = ref dummy A better solution would be to use options. If it is possible for some of your vars to be uninitialized, this unitialized state should be able to be easily filtered: let current = ref None; ... current := Some(generate_struct foo bar); ... match current with | None -> failwith "This shouldn't be uninitializable at this stage." | Some current -> ... It's way cleaner than if(!current==dummy) tests. ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr