From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.1 required=5.0 tests=AWL,SPF_SOFTFAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id D3437BBAF for ; Mon, 19 Jan 2009 18:52:12 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsIBABlMdEnBvsFKl2dsb2JhbACUBwEBAQEBCBUHvjSFcw X-IronPort-AV: E=Sophos;i="4.37,290,1231110000"; d="scan'208";a="22720965" Received: from dnsp.umh.ac.be (HELO hermes1.umh.ac.be) ([193.190.193.74]) by mail1-smtp-roc.national.inria.fr with ESMTP; 19 Jan 2009 18:52:12 +0100 Received: from poincare.swapping.umh.ac.be ([10.102.100.31]) by hermes1.umh.ac.be (8.14.2/8.13.6) with ESMTP id n0JHo1Wi278588; Mon, 19 Jan 2009 18:50:01 +0100 Received: from localhost ([127.0.0.1] ident=trch) by poincare.swapping.umh.ac.be with esmtp (Exim 4.69) (envelope-from ) id 1LOyIF-0007nU-Gy; Mon, 19 Jan 2009 18:52:11 +0100 Date: Mon, 19 Jan 2009 18:52:11 +0100 (CET) Message-Id: <20090119.185211.510590053606729883.Christophe.Troestler+ocaml@umons.ac.be> To: OCaml Mailing List Subject: Re: Visitor in OCaml From: Christophe TROESTLER In-Reply-To: <527cf6bc0901190841l3247ada1kfc86847aac1445d1@mail.gmail.com> References: <200901171659.36732.jon@ffconsultancy.com> <871vuz2rm7.fsf_-_@aryx.cs.uiuc.edu> <527cf6bc0901190841l3247ada1kfc86847aac1445d1@mail.gmail.com> X-Face: #2fb%mPx>rRL@4ff~TVgZ"<[:,oL"`TUEGK/[8/qb58~C>jR(x4A+v/n)7BgpEtIph_neoLKJBq0JBY9:}8v|j Organization: University of Mons-Hainaut X-Mailer: Mew version 6.0.51 on Emacs 22.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.64 on 193.190.193.76 X-Spam: no; 0.00; ocaml:01 christophe:01 troestler:01 christophe:01 troestler:01 ocaml:01 0100,:01 expr:01 expr:01 camlp:01 camlp:01 variants:01 2009:98 storm:98 2000.:98 On Mon, 19 Jan 2009 17:41:35 +0100, blue storm wrote: > > On 1/19/09, Yoann Padioleau wrote: > > What we want is really give code like > > > > let my_analysis program = > > analyze_all_expressions program (fun expr -> > > match expr with > > | FunCall (e, es) -> do_something() > > | _ -> > > ) > > > > The problem is how to write analyze_all_expressions > > and find_a_way_to_recurse_for_all_the_other_cases. > > You should have a look at the Camlp4 "metaprogramming" facilities : > http://brion.inria.fr/gallium/index.php/Camlp4MapGenerator You may also be interested in the paper "Code reuse through polymorphic variants" by Jacques Garrigue: http://www.math.nagoya-u.ac.jp/~garrigue/papers/fose2000.html Regards, ChriS