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 JAA21261 for caml-red; Mon, 16 Oct 2000 09:52:45 +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 JAA21767 for ; Mon, 16 Oct 2000 09:49:28 +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 e9G7nOP10868; Mon, 16 Oct 2000 09:49:24 +0200 (MET DST) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA21632; Mon, 16 Oct 2000 09:49:24 +0200 (MET DST) From: Pierre Weis Message-Id: <200010160749.JAA21632@pauillac.inria.fr> Subject: Re: Seeking pratical tutorial or examples. In-Reply-To: <200010160046.UAA57403@sanson.reyes.somos.net> from Francisco Reyes at "Oct 15, 100 08:52:25 pm" To: fran@reyes.somos.net Date: Mon, 16 Oct 2000 09:49:23 +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 > I have looked at the caml site, the hump and all I links I could > find from the main site. [...] In my mind, it seems as if you have completely missed the FAQ of the language ... > Isn't there a code snippet/samples page? > > What I have tried so far are the intro on the Ocaml Manual, the > "Functional Programming using Caml light" and "One hundred lines > of Caml". > > Comments on the 3 sources I mentioned above: > ** Ocaml Manual: The intro is not bad, except that for those of > us coming from languages without a built in interactive system > we may not be as interested to start with that. Why? because > although great for learning it is of not much use unless we just > want to try simple things. [...] Bizarre: you do not want to start by simple things ? If you do want to start by material that are not ``simple things'', you definitely have to read the pretty good bunch of examples that is generally refered to as ``the Objective Caml compiler''. It is not interactive, it is great for learning, and in some cases definitively not simple (I would suggest the following road-map: start with the Objective Caml libraries (directories stdlib and otherlibs), then bravely start reading the compiler sources: first the Yacc parser and its associated lexer (directory parsing), then take a breath and read the type-checker (directory typing), breath again and continue with the pattern matching compiler (directory bytecomp), then breath a lot and end with the delicious native code compiler (directory asmcomp)). > I think the following order may be more benefitial to someone > coming from languages such as C/pascal. Excellent: you are exactly describing the order of presentation of the FAQ, that has been intended for just that kind of people. The first page of the FAQ for beginners, has the following items entries, in that order: * What is the syntax of the language ? * What are the basic data structures ? * Numbers: integers and floating point numbers. * Characters * Character strings * Arrays * Lists * Booleans * Nothing * References * Pairs * Other data structures * What are the basic control structures ? * How to perform a test ? * How to perform a case analysis ? * How to perform a test within a case analysis ? * How to write a loop ? * How to exit form a loop ? (break, exit, abort, return ...) * How to catch errors ? * How to signal errors (raise exceptions) ? * What are the predefined exceptions (errors) ? * How to define a function ? * How to define a procedure ? > -Start by having something which shows a compiled program and a > few basic statements (i.e. ask for name and then print hello > . http://pauillac.inria.fr/caml/FAQ/FAQ_DEBUTANT-eng.html#quellesyntaxe > -Cover data types and show the functions to read them and > display them. No fancy explanation about "channels" just give > examples using print functions and whatever is used to read info > into a variable. http://pauillac.inria.fr/caml/FAQ/FAQ_DEBUTANT-eng.html#donnees_de_base-eng.html > -Loops and branching: "for" and "if" http://pauillac.inria.fr/caml/FAQ/FAQ_DEBUTANT-eng.html#controle_de_base-eng.html While, match and exceptions are also covered. > -Cover functions http://pauillac.inria.fr/caml/FAQ/FAQ_DEBUTANT-eng.html#function_definition > -Basic file I/O http://pauillac.inria.fr/caml/FAQ/FAQ_DEBUTANT-eng.html#ios Printing is also covered at: http://pauillac.inria.fr/caml/FAQ/FAQ_DEBUTANT-eng.html#impression > -String handling http://pauillac.inria.fr/caml/FAQ/donnees_de_base-eng.html#strings > -More advanced data structures/types: arrays, user defined data > types, lists. http://pauillac.inria.fr/caml/FAQ/donnees_de_base-eng.html#vects http://pauillac.inria.fr/caml/FAQ/donnees_de_base-eng.html#lists http://pauillac.inria.fr/caml/FAQ/qrg-eng.html > -The interactive system http://pauillac.inria.fr/caml/FAQ/ > And of course on all those steps start showing the user the way > things are written in Ocaml and how things are called in it. The same references, plus the Quick Reference Guide for Caml that gives you the syntactic constructs along with examples: http://pauillac.inria.fr/caml/FAQ/qrg-eng.html > ** Functional Programming using Caml Light > I am up to chapter 5 and I am yet to dream of how to actually > write a complete program. Even after I jumped chapters ahead to > chapter 9, Basic I/O, there are one line descriptions or trivial > use of the fucntions, but I didn't even see a simple brief > program to show all elements together. The document almost seems > like reference material, except that it is too > descriptive/narrative to be that. Right. It is not a reference manual, although it describes a type-checker and a compiler for (a subset of) Caml. > ** One Hundred lines of Ocaml: This is enough to give a "taste" > of the language, but far from been enough to start hacking. Right, it just appears in the FAQ under the title: A taste of Caml > Have a missed a kinder/gentler tutorial somewhere? May be the FAQ ? > Somewhere on the caml site I saw a mention about a series of > examples that come with the compiler. The FreeBSD port I got > didn't have them and I was unable to find them on the web site > (caml.inria.fr) Those examples are written for Caml Light and burried from the book ``Le langage Caml''. I translated them into Objective Caml, but have not linked them to the Caml web site, since there is no english explanations on those examples (the book ``Le langage Caml'' has not yet been translated into english). > francisco > Moderator of the Corporate BSD list > http://www.egroups.com/group/BSD_Corporate PS1: I hope you will find what you need in the FAQ. In any case, please let me know if you have some addition to suggest to the FAQ's tutorial. PS2: Also, when you are writing your first big Caml programs, don't miss the very relevant Caml Programming Guide Lines: http://pauillac.inria.fr/caml/FAQ/pgl-eng.html that also gives some useful hints on how to program in Caml. Pierre Weis Moderator of the Caml list http://pauillac.inria.fr/caml/FAQ/