From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA11228; Tue, 22 May 2001 19:09:43 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 TAA11218 for ; Tue, 22 May 2001 19:09:42 +0200 (MET DST) Received: from shell5.ba.best.com (shell5.ba.best.com [206.184.139.136]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f4MH9cn18552 for ; Tue, 22 May 2001 19:09:41 +0200 (MET DST) Received: from localhost (bpr@localhost) by shell5.ba.best.com (8.9.3/8.9.2/best.sh) with ESMTP id KAA26672; Tue, 22 May 2001 10:09:37 -0700 (PDT) Date: Tue, 22 May 2001 10:09:37 -0700 (PDT) From: Brian Rogoff To: Miles Egan cc: caml-list@inria.fr Subject: Re: [Caml-list] lisp -> ocaml In-Reply-To: <20010522093341.A97425@caddr.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, 22 May 2001, Miles Egan wrote: > Which fails to compile, for obvious reasons. Is the solution to refactor the > code into a nonrecursive form? In Caml you declare mutually recursive functions and types with a "rec" and an "and" let rec apply_op op = ... and achieve goal ops = ... You can also use the same syntax to emulate "where" clauses of Haskell and other FPLs. > Second, the PAIP code makes fairly heavy use of Lisp's symbolic features and > uses symbols as a kind of type tag but also as printable strings. I've been > using variants, both traditional and polymorphic, as a substitute, but they're > not really quite equivalent. For example, one of the first programs is a > simple implementation of the old GPS (general problem solver), which > manipulates sets of states. Lisp provides set operations on lists and allows > printing of symbols, which makes it possible to both manipulate "state" lists > and print them with very little code. I can't use variants with the same > flexibility because I have to provide an explicit ordering if I want to use > them as set members and I can't print them because there doesn't seem to be a > way to print something like: One thing you can do is write polymorphic versions of the OCaml library set functor, which you'll need anyways as soon as you want to have a type recursive with a functor instantiation. Insert long whining and sobbing here about how this is a pain :-). For this problem though, it seems that you just want nullary constructors of a sum type to behave as integers, as in C or Ada. Easy enough with a bit of boilerplate code. > type t = ONE | TWO | THREE > > as "ONE", "TWO", "THREE". let pos = function ONE -> 1 | TWO -> 2 | THREE -> 3 let image = function ONE -> "uno" | TWO -> "dos" | THREE -> "tres" > I'm using strings in the meantime but this isn't very satisfying. Indeed. -- Brian ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr