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 VAA23981; Mon, 17 Dec 2001 21:42:07 +0100 (MET) 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 VAA24213 for ; Mon, 17 Dec 2001 21:42:06 +0100 (MET) Received: from Snoopy.UCIS.Dal.Ca (Snoopy.UCIS.Dal.Ca [129.173.1.10]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id fBHKg4123731; Mon, 17 Dec 2001 21:42:04 +0100 (MET) Received: from 129.173.2.173 (WebMail.UCIS.Dal.Ca [129.173.1.95]) by Snoopy.UCIS.Dal.Ca (8.10.1/8.10.1) with ESMTP id fBHKg3a23721; Mon, 17 Dec 2001 16:42:03 -0400 (AST) X-WebMail-UserID: mabaleka@mail.cs.dal.ca Date: Mon, 17 Dec 2001 16:41:28 -0400 From: Emmanuel Mabaleka To: Caml-list , Pierre.Weis@inria.fr X-EXP32-SerialNo: 00002905 Subject: [Caml-list] Caml Light syntax errors Message-ID: <3C2C63A9@129.173.2.173> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Mailer: WebMail (Hydra) SMTP v3.61.07 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hie, I have similar problems of syntax errors with the compilation of Caml programs in Chapter 11 of the "Functional programming using Caml Light", 1995 from http://caml.inria.fr/distrib-caml-light-eng.htm using the Ocaml 3.02 compiler. I am interested in writing real standalone applications but like sergei, I run into errors which are not documented. The other day, I spent several hours pondering why the count.ml program on p.79 didn't work. It was only after emailing the Caml-list on Wed, 12 Dec 2001 23:44:22 that I was advised to replace "std_in" with "stdin". That difference is not listed in the email you sent to Sergei below and in any FAQ. I am currently trying to get the continuation of that count program to work i.e. after it has been split into several files but for the counter.mli program, I am getting a syntax error on line "value new: int-> counter"; for the counter.ml program, there's a syntax error on line "type counter = {mutable val:int};;". Is there a comprehensive list of syntax changes between Caml and OCaml? What would be really helpful for Ocaml would be a simple example application showing the main concepts without using the interactive mode. I think a newbie list would be an excellent good idea as suggested by "Collin Monahan" on Thu, 13 Sep 2001 12:29:04. To: serge777@my-Deja.com Subject: Re: [newbie] Caml Light vs Objective Caml From: Pierre Weis Date: Sun, 20 Aug 2000 21:50:36 +0200 (MET DST) Cc: caml-list@inria.fr In-Reply-To: from serge777 at "Aug 18, 100 08:35:37 am" ------------------------------------------------------------------------------ -- [...] > Some Caml Light code from this book (and form others) does not work > for Ocaml, for example, Ocaml report a syntax > error for a definition from page 25 > > let neg = fun true -> false | false -> true ;; Yes, you should write function instead of fun here. > 1) Could anyone point out other known basic discrepancy between Caml > Light and Ocaml that were not mentioned in the FAQ? There are a few of them, namely: - predefined identifiers that has changed (module vect is now module Array) - module access conventions (module__ident is now Module.ident), hence String.sub, instead of sub_string, and String.blit instead of blit_string - case conventions have been enforced in Objective Caml. > 2) I know there is a French book "Diveloppement d'applications avec > Objective Caml". Is it suits for studying functional programming and > OCaml for peoples without any background in the functional programming? It is a good book with many interesting examples, worth reading. There are a lot of other french books for beginners, have a look at http://pauillac.inria.fr/caml/books-eng.html > 3) Why did the meaning of "fun" change? The raw ``meaning'' is still the same: fun introduces a function definition; however the syntax of the construction, and the kind of function definitions the fun keyword introduces has changed. Hence, this is one of the more difficult changes you have to make when you want to translate to O'Caml some code that heavily uses this construct. I summarize here the differences: What is perfectly equivalent: ----------------------------- Introducing a curried function with multiple arguments, as in fun x y z -> expression What has slightly changed: -------------------------- Introducing a pattern matching function with 1 argument; you must change the keyword fun to the keyword function. Hence fun true -> false | false -> true becomes function true -> false | false -> true What has completely changed: ---------------------------- In Objective Caml, the notion of ``curried pattern matching'' (as defined in older versions of Caml) has been removed, because this feature has been considered as having a too questionable (and complex to understand) semantics. The ``curried pattern matching'' is the ability to performs multiple pattern matching in parallel, here multiple pattern matching when defining a function. Instead of the O'Caml code fun x y -> match x, y with | 1, 1 -> bli | _, 0 -> bla | _, _ -> blu you could write the Caml Light specific fragment fun | 1 1 -> bli | _ 0 -> bla | _ _ -> blu So you need to perform the converse transformation, which is fortunately easy if not completely mechanical. > Thank you in advance. > > Sergei. You're welcome. Pierre Weis INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/ ------------------- 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