From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 9F38EBC2F for ; Fri, 26 Nov 2004 02:46:20 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iAQ1kJiD028900 for ; Fri, 26 Nov 2004 02:46:19 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA07779 for ; Fri, 26 Nov 2004 02:46:18 +0100 (MET) Received: from swordfish.cs.caltech.edu (swordfish.cs.caltech.edu [131.215.44.124]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id iAQ1kHvW030025 for ; Fri, 26 Nov 2004 02:46:17 +0100 Received: from orchestra.cs.caltech.edu (orchestra.cs.caltech.edu [131.215.44.20]) by swordfish.cs.caltech.edu (Postfix) with ESMTP id 81556DF260; Thu, 25 Nov 2004 17:46:16 -0800 (PST) Received: by orchestra.cs.caltech.edu (Postfix, from userid 2554) id 655389BDA9; Thu, 25 Nov 2004 17:46:11 -0800 (PST) From: Michael Vanier To: shoh@compiler.kaist.ac.kr Cc: caml-list@inria.fr In-reply-to: <002601c4d351$74871cc0$1501a8c0@hama> (shoh@compiler.kaist.ac.kr) Subject: Re: [Caml-list] Experiences with learning OCaml? References: <3033.66.167.163.102.1101382830.squirrel@acs-webmail.ucsd.edu> <20041125205612.2A19E9BDA9@orchestra.cs.caltech.edu> <002601c4d351$74871cc0$1501a8c0@hama> Message-Id: <20041126014611.655389BDA9@orchestra.cs.caltech.edu> Date: Thu, 25 Nov 2004 17:46:11 -0800 (PST) X-Miltered: at concorde with ID 41A68AEB.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 41A68AE9.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; vanier:01 mvanier:01 caml-list:01 ocaml:01 compiler:01 ocaml:01 metaocaml:01 translating:01 sicp:01 translated:01 haskell:01 lazy:01 beginner's:01 beginners:01 syntax:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: > From: "SooHyoung Oh" > Date: Fri, 26 Nov 2004 09:47:06 +0900 > > Anyway, in my experience, the difficult parts to convert are > 1. cond-expression -> should be rewritten using pattern-matching; need new > examples cond is very often used for the equivalent of pattern matching in scheme. If you need more flexibility you can always use pattern matching with a when clause e.g. let n = 10 in match n with | m when m < 0 -> -1 | m when m = 0 -> 0 | m -> 1;; > 2. symbol information -> decide which one is better? strings or varient > types? Symbols per se don't exist in ocaml (at least without using camlp4), and the whole notion of code-as-data is foreign to the ocaml world (again, not counting things like camlp4 and metaocaml), so some examples are going to be pretty hard to translate. Still, you can learn a lot by translating like this. I went through part 3.5 of SICP and translated the examples into ocaml; the results were very interesting, though haskell would have been more elegant for those examples because they all involved lazy evaluation. I'm not sure how appropriate ocaml is as a beginner's language. I teach both scheme and ocaml now, and ocaml is very well-liked by advanced programmers (one of whom came up to me raving about his "programming epiphany" after learning ocaml), but I think it would overwhelm beginners. The syntax is pretty involved, for one thing, and there are just a lot of concepts to learn. Cousineau and Mauny's book _The Functional Approach to Programming_ is a good attempt to teach functional programming and ocaml (actually caml-light, but it's basically the same) to a fairly naive audience. Mike