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 QAA00567; Mon, 27 Oct 2003 16:21:53 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 QAA10565 for ; Mon, 27 Oct 2003 16:21:51 +0100 (MET) Received: from elios.disi.unige.it (proxy.disi.unige.it [130.251.61.19]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h9RFLo121203 for ; Mon, 27 Oct 2003 16:21:50 +0100 (MET) Received: from discus.disi.unige.it (balat [130.251.152.9]) by elios.disi.unige.it (8.9.3/8.9.3) with ESMTP id QAA28788; Mon, 27 Oct 2003 16:19:06 +0100 (MET) From: "Vincent Balat [prof Moggi team]" MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Message-ID: <16285.14053.374835.323880@elios.disi.unige.it> Date: Mon, 27 Oct 2003 16:16:53 +0100 To: "Ben Kavanagh" Cc: Subject: Re: [Caml-list] partial eval question In-Reply-To: <004a01c39c2b$819db8f0$1fcf2952@Archimedes> References: <004a01c39c2b$819db8f0$1fcf2952@Archimedes> X-Mailer: VM 7.17 under Emacs 21.3.1 Reply-To: Vincent Balat X-Loop: caml-list@inria.fr X-Spam: no; 0.00; moggi:01 caml-list:01 danvy:01 normalized:01 val:01 val:01 normalized:01 damien:01 metaocaml:01 closures:01 bug:01 faq:01 faq:01 beginner's:01 beginners:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I am working on a "type-directed" partial evaluator for OCaml. I did an implementation a few years ago with Olivier Danvy (see http://www.pps.jussieu.fr/~balat/publications/balat-danvy.pdf) But it is still*experimental*: - only a small subset on ocaml - need a modified version of ocaml with a "call/cc" operator ex: # let rec power mul one x n =3D=20 if n=3D0 then one=20 else (mul x (power mul one x (n-1)));; =20 (* We close by mul and one because the function to be normalized must be mostly polymorphic *) val power : ('a -> 'b -> 'b) -> 'b -> 'a -> int -> 'b =3D # let power3 mul one x =3D power mul one x 3;; val power3 : ('a -> 'b -> 'b) -> 'b -> 'a -> 'b =3D # normalize "power3";; - : unit =3D () (* Now the function power3 is normalized *) (* You can print the normalized code by: *) # normalize_nf "power3";; - : NormalForms.computation =3D (fun v7 v8 v9 -> let v10 =3D v7 v9 in let v11 =3D v10 v8 in let v12 =3D v7 v9 in let v13 =3D v12 v11 in let v14 =3D v7 v9 in let v15 =3D v14 v13 in v15) It is not available on the web any more (it was for ocaml 1.05) but I can send it to you if you are interested. I'm planning to update it and to try to extend it to a larger subset of ocaml. There are still a lot of opened questions to solve before having it included in ocaml... Otherwise, as pointed by Damien Pous, you can have a look at MetaOCaml, which is a multi-level language based on ocaml, that is a language that allows you to manipulate source code (program generation). Vincent Balat ---- Ben Kavanagh =E9crit : >=20 > Say I have a function such as pow defined as >=20 > let pow n x =3D=20 > let rec pow_iter (n1, x1, p1) =3D=20 > if (n1 =3D 0) then p1=20 > else if (n1 mod 2 =3D 0)=20 > =09=09 then pow_iter(n1/2, x1*x1, p1)=20 > else pow_iter(n1-1, x1, p1*x1) > in pow_iter(n, x, 1);; >=20 > and I say=20 >=20 > let pow2 =3D pow 2 >=20 > Are there any ML implementations that would automatically perform > partial evaluation to create pow2 instead of using closures, possibl= y > unfolding the pow_iter call? Would Caml ever have this capability? >=20 > Ben >=20 >=20 > ------------------- > To unsubscribe, mail caml-list-request@inria.fr Archives: http://cam= l.inria.fr > Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inr= ia.fr/FAQ/ > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >=20 ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners