From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA22146 for caml-redist@pauillac.inria.fr; Sat, 13 May 2000 11:38:19 +0200 (MET DST) Resent-Message-Id: <200005130938.LAA22146@pauillac.inria.fr> 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 TAA07747 for ; Fri, 12 May 2000 19:39:14 +0200 (MET DST) Received: from csla.csl.sri.com (csla.csl.sri.com [192.12.33.2]) by concorde.inria.fr (8.10.0/8.10.0) with ESMTP id e4CHdC903850 for ; Fri, 12 May 2000 19:39:13 +0200 (MET DST) Received: from cylinder.csl.sri.com (IDENT:filliatr@cylinder.csl.sri.com [130.107.15.112]) by csla.csl.sri.com (8.9.1/8.9.1) with ESMTP id KAA12460; Fri, 12 May 2000 10:39:04 -0700 (PDT) Received: (from filliatr@localhost) by cylinder.csl.sri.com (8.9.3/8.8.7) id KAA25721; Fri, 12 May 2000 10:39:03 -0700 X-Authentication-Warning: cylinder.csl.sri.com: filliatr set sender to filliatr@cylinder.csl.sri.com using -f From: Jean-Christophe Filliatre MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <14620.16823.427013.241014@cylinder.csl.sri.com> Date: Fri, 12 May 2000 10:39:03 -0700 (PDT) To: Amit Dubey Cc: caml-list@inria.fr Subject: Re: The Unix module & records In-Reply-To: <200005121655.MAA03138@hopper.math.uwaterloo.ca> References: <200005121655.MAA03138@hopper.math.uwaterloo.ca> X-Mailer: VM 6.62 under Emacs 20.4.1 Reply-To: filliatr@csl.sri.com (Jean-Christophe Filliatre) Resent-From: weis@pauillac.inria.fr Resent-Date: Sat, 13 May 2000 11:38:19 +0200 Resent-To: caml-redist@pauillac.inria.fr > 1: let main () = > 2: let file_info : Unix.stats = Unix.stat Sys.argv.(1) in > 3: let fd = Unix.openfile Sys.argv.(1) [ Unix.O_RDONLY ] perm in > 4: let buffer = ref "" in > 5: let bytes_read = Unix.read (fd) (buffer) (file_info.st_size) in > > > But it fails with the error "Unbound record field label st_size" on line 5. > I can't explain why this is happening; looking at the Unix.ml file, I see > the st_size field in the Unix.stats record. Any suggestions would be > appreciated. Since you didn't open the Unix module with "open Unix" you have to qualify any identifier from that module with "Unix." (as you did for stat, read, ... by the way), including the field name st_size. So you should have written "file_info.Unix.st_size". As you are probably going to say, it becomes quite heavy. Thus, since you use many identifiers from the Unix module, you should rather open it, like this : ====================================================================== open Unix let main () = let file_info = stat Sys.argv.(1) in let fd = openfile Sys.argv.(1) [ O_RDONLY ] perm in let buffer = ref "" in let bytes_read = read fd buffer file_info.st_size in ====================================================================== -- Jean-Christophe Filliatre Computer Science Laboratory Phone (650) 859-5173 SRI International FAX (650) 859-2844 333 Ravenswood Ave. email filliatr@csl.sri.com Menlo Park, CA 94025, USA web http://www.csl.sri.com/~filliatr