Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] lisp to ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-09-18 (14:06)
From: Thomas Fischbacher <Thomas.Fischbacher@P...>
Subject: Re: [Caml-list] lisp to ocaml

On Sun, 18 Sep 2005, Jonathan Roewen wrote:

> Does anyone know of a tool that can convert lisp to ocaml (or
> something other ML dialect)?

For ANSI Common LISP, this could at best work at the level of a LISP 
interpreter (or compiler) written im ML. You cannot directly compile LISP 
code to ML code in the sense that

(defun factorial (n)
      ((walk (so-far todo)
	 (if (= todo 0)
	   (walk (* so-far todo) (- todo 1)))))
    (walk 1 n)))

would become

let factorial n =
  let rec walk so_far todo =
      if todo=0
      then so_far
      else walk (so_far*todo) (todo-1)
  in walk 1 n

for a ton of reasons.

> Just all the parentheses gets a bit confusing for a first
> look at lisp ;-)

The trick is:

(1) Do not look at the parentheses. Read and write code by indentation.

(2) Use a text editor that helps you with this.

(3) paren-sensitive syntax highlighting is a great thing.

You will find the parens to be much less confusing once you learned not to 
look at them. :-)

regards,                   (o_
 Thomas Fischbacher -  //\
(lambda (n) ((lambda (p q r) (p p q r)) (lambda (g x y)           V_/_
(if (= x 0) y (g g (- x 1) (* x y)))) n 1))                  (Debian GNU)