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=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 2C116BBC1 for ; Thu, 13 Mar 2008 08:10:49 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AoUBAKBw2EfRVYT2kmdsb2JhbACQcwEBAQEHBAQJChaNY4Z3 X-IronPort-AV: E=Sophos;i="4.25,492,1199660400"; d="scan'208";a="23706132" Received: from an-out-0708.google.com ([209.85.132.246]) by mail4-smtp-sop.national.inria.fr with ESMTP; 13 Mar 2008 08:10:37 +0100 Received: by an-out-0708.google.com with SMTP id b15so1082552ana.102 for ; Thu, 13 Mar 2008 00:10:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=9iHh1qeMkLEWArKcwi7T5QrHfgFsOp0ZLs9+2d0lShE=; b=gT0BVywSXQ14YNfEjxRaDNK1VbdrKf8wz0UZbsFSzbkXAX0l3AmlzsL0WlVBXGszAdciR5/Chr2pnRmBfZuEUFC/ON/McHAlSTiimluWlc86Flxd1rl/Qi2ldMuqxUvwTRp4YTBtGCIERBc1Pri3RziWV9Y9TWDpRDNX2Rx4BkI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Tgn+lnO4J7rzwfIMzAs2ATQrO1KED1BigJWwesYBCOixXDRaVBeubXTezb5tuOYsARn1UoIYt7jYax3MwDBYrQp+7FtYb40YRrnnyTJzskc+wySgw+tEDsmOooCPYyngWJf7TIw5hg1yuOddMEbuHPhWNIpdEoHZbFtoczUljZ0= Received: by 10.100.107.7 with SMTP id f7mr18756741anc.74.1205392236025; Thu, 13 Mar 2008 00:10:36 -0700 (PDT) Received: by 10.100.136.16 with HTTP; Thu, 13 Mar 2008 00:10:36 -0700 (PDT) Message-ID: Date: Thu, 13 Mar 2008 15:10:36 +0800 From: "Ludovic Coquelle" To: Andrej.Bauer@andrej.com Subject: Re: [Caml-list] invoke function from its name as string Cc: caml-list@yquem.inria.fr In-Reply-To: <47D8CE92.2020009@fmf.uni-lj.si> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <47D8CE92.2020009@fmf.uni-lj.si> X-Spam: no; 0.00; andrej:01 andrej:01 ocaml:01 ocaml:01 'make:01 'make:01 blog:98 invoke:01 wrote:01 wrote:01 regex:01 compile:01 caml-list:01 functions:01 functions:01 On Thu, Mar 13, 2008 at 2:49 PM, Andrej Bauer wrote: > Ludovic Coquelle wrote: > > (re-send as it seems it didn't go through) > > It did. Sorry for the double post (gmail probably filtered the mail I sent to list). > > First, hello everyone as it is my first message to this list ;) > > > > I'm trying to solve this problem: > > I have a module name and function name in string variables, > > and I would like to call this function, like : > > let mod = "MyMod" in > > let fn = "my_fun" in > > what_come_here mod fn > > > > Can this problem be solved? > > If you are new to ocaml then we can help you much better if you explain > what problem you are trying to solve. It looks like you are trying to > write in Ocaml something that is common in Python/perl/shell. There is > likely to be a different, better way of doing the same thing in Ocaml. > > Best regards, > > Andrej > Thanks for this answer. Problem I'm trying to solve is the following: I use 'make_suite' which is a program that do regex matching on source code to extract a list of function that looks like OUnit tests; from this list, it write an ocaml source code file which is a test case that call all the previous functions found. (see: http://skydeck.com/blog/programming/unit-test-in-ocaml-with-ounit/) Now, instead of having a program which write a source file that I have to compile and run, I would prefer if I can change 'make_suite' to create the test case and run it directly. Thus, I have a list of function's names as string and I would like a list of functions. Is this possible? Is there a better way to achieve automatic test case construction? PS: this is not a *real problem* to use an intermediate file; just wanna learn if we can do without :)