Version française
Home     About     Download     Resources     Contact us    
Browse thread
Experiences with learning OCaml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Michael Vanier <mvanier@c...>
Subject: Re: [Caml-list] Experiences with learning OCaml?
> From: "SooHyoung Oh" <shoh@compiler.kaist.ac.kr>
> 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