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 XAA19969 for caml-red; Tue, 8 Aug 2000 23:10:26 +0200 (MET DST) 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 XAA20041 for ; Tue, 8 Aug 2000 23:10:10 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.10.0/8.10.0) with ESMTP id e78LA8P23112; Tue, 8 Aug 2000 23:10:08 +0200 (MET DST) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA20025; Tue, 8 Aug 2000 23:10:08 +0200 (MET DST) From: Pierre Weis Message-Id: <200008082110.XAA20025@pauillac.inria.fr> Subject: Re: Imperative programming in Caml In-Reply-To: from Walid Taha at "Aug 8, 100 08:30:19 pm" To: taha@cs.chalmers.se (Walid Taha) Date: Tue, 8 Aug 2000 23:10:08 +0200 (MET DST) Cc: caml-list@inria.fr X-Mailer: ELM [version 2.4ME+ PL28 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: weis@pauillac.inria.fr Hi Walid > > If you write: > > > > imperative call; > > let x = blah in > > imperative call > > > > then you get a little distracted by the indentation. > > Got it! > > > Mmm. I don't think you're going to have much success at showing that > > O'Caml is a reasonable language without using at least some > > polymorphism. Perhaps this restatement of my previous code would > > help, though: > > > > type optional_int = > > | No_Int > > | Some_Int of int > > I feel you were "righter" the first time. An "option" type is somehow > semanticaly implict in having "null/nill" in every pointer. So, I think > it is reasonable to interpreter "'a pointer" as "'a option ref". This > also suggests a naturally way to translate imperative programs to > functional programs systematically. > > Thanks again for the great feedback. > > Walid. Your problem seems to have something to do with elementary programming in Caml; you may have a look at the documentation, in particular the FAQ where basic indentation hints are given in the programming guide lines (http://pauillac.inria.fr/caml/FAQ/pgl-eng.html), and questions about imperative programming in Caml including the existence of imperative pointers and their encoding in Caml are discussed in details (http://pauillac.inria.fr/caml/FAQ/pointers-eng.html). Note: if you really do not want to use any kind of polymorphism, I'm afraid you will have a bad time to write and explain imperative programming examples in Caml, since you cannot use references ('a ref), nor arrays ('a array), nor options ('a option), nor lists ('a list); if you also consistently banish polymorphism from your function type schemes, what could you do without the basic predicates such that (=) (that has type 'a -> 'a -> bool), or even any comparison predicates (<, <=, <>, ...) that are also polymorphic ? Hope this helps, Pierre Weis INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/