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 TAA25118; Wed, 7 Apr 2004 19:27:51 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 TAA24911 for ; Wed, 7 Apr 2004 19:27:50 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i37HRJYM025322; Wed, 7 Apr 2004 19:27:19 +0200 Received: from bourg.inria.fr (bourg.inria.fr [128.93.11.100]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA25063; Wed, 7 Apr 2004 19:27:18 +0200 (MET DST) Received: from starynke by bourg.inria.fr with local (Exim 4.31) id 1BBGp6-0003HL-J7; Wed, 07 Apr 2004 19:26:48 +0200 Date: Wed, 7 Apr 2004 19:26:48 +0200 To: Richard Jones , caml-list@inria.fr Subject: Re: [Caml-list] Function forward declaration? Message-ID: <20040407172648.GA12511@bourg.inria.fr> References: <60532B15DF92FD4693AA89B2F7E01D8F013F29EC@tmex02> <00cf01c41bd6$391b53a0$0203a8c0@hoedic> <20040406175320.GA19840@redhat.com> <1081279717.16531.6.camel@qrnik> <002901c41c65$b53e4c50$19b0e152@warp> <1081345936.19232.579.camel@pelican> <20040407141519.GA6618@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20040407141519.GA6618@redhat.com> User-Agent: Mutt/1.5.5.1+cvs20040105i From: Basile Starynkevitch X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 basile:01 basile:01 2004:99 foo:01 mli:01 foo:01 mli:01 'return':99 camlp:01 val:01 failwith:01 implemented:01 printf:01 sprintf:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 98 On Wed, Apr 07, 2004 at 03:15:19PM +0100, Richard Jones wrote: > > The trouble seems to be that I have a perfectly practical and > reasonable desire to see prototypes added to the language, because, > believe it or now, it helps to solve some problems in the Real World. > Now if there's some deep reason why it's actually impossible I would > understand, but plenty of other languages (eg. C) seem to have > prototypes and they get along just fine. What I understand you call prototypes are signature items (or I misunderstood your point). You can have use signatures and modules, either by compiling both foo.mli & foo.ml (with the prototypes in foo.mli & the implementations in foo.ml) or by having, inside your compilation unit, a signature (or module type) and an structure (or module). [....] > (Same, by the way, goes for a 'return' statement which OCaml is crying > out for). For your information, the revised syntax (provided by camlp4) does have (IIRC) a return keyword (but I don't remember more, and I never used it). Regarding this thread, a useful trick (somehow a hack, but used in the compiler itself) is to declare a reference to a function initialised to a function throwing an exception: (** in foo.mli *) val rf: (int -> string) ref (** in foo.ml *) let rf = ref ((fun x -> failwith "rf not yet implemented") : (int -> string)) (* in a bar.ml *) Foo.rf := (fun x -> Printf.sprintf "the real rf %d" x);; this trick is needed e.g. when two modules are mutually recursive, eg if a function of foo calls a function of bar which calls the first function of foo. (In the compiler, you can find such an instance - Env;check_modtyping_inclusion is a reference to Includemod.check_modtype_inclusion - in directory caml/typing/ ) Regards. -- Basile STARYNKEVITCH -- basile dot starynkevitch at inria dot fr Project cristal.inria.fr - INRIA Rocquencourt http://cristal.inria.fr/~starynke --- all opinions are only mine ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners