Browse thread
[Caml-list] lisp to ocaml
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ 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) (labels ((walk (so-far todo) (if (= todo 0) so-far (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, tf@cip.physik.uni-muenchen.de (o_ Thomas Fischbacher - http://www.cip.physik.uni-muenchen.de/~tf //\ (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)