From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 9051ABC3C for ; Mon, 15 Aug 2005 22:14:45 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j7FKEjV7031075 for ; Mon, 15 Aug 2005 22:14:45 +0200 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 WAA28157 for ; Mon, 15 Aug 2005 22:14:44 +0200 (MET DST) Received: from out2.smtp.messagingengine.com (out2.smtp.messagingengine.com [66.111.4.26]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j7FKEhUQ021203 for ; Mon, 15 Aug 2005 22:14:44 +0200 Received: from frontend2.messagingengine.com (frontend2.internal [10.202.2.151]) by frontend1.messagingengine.com (Postfix) with ESMTP id 9326BCC945A; Mon, 15 Aug 2005 16:14:42 -0400 (EDT) X-Sasl-enc: /BdrIgiOlxxgDunFV6PU5S526Z7WBMVyrk50UXpWju9b 1124136880 Received: from [172.16.112.115] (burnham.ljcrf.edu [192.231.106.2]) by frontend2.messagingengine.com (Postfix) with ESMTP id 9BF62570326; Mon, 15 Aug 2005 16:14:39 -0400 (EDT) Date: Mon, 15 Aug 2005 13:14:29 -0700 (PDT) From: Martin Jambon X-X-Sender: martin@droopy To: Dmitri Boulytchev Cc: caml-list@inria.fr Subject: Re: [Caml-list] String representation of the expression: may camlp4 help? In-Reply-To: <43009DF2.8090101@tepkom.ru> Message-ID: References: <43009DF2.8090101@tepkom.ru> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Miltered: at concorde with ID 4300F7B5.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4300F7B3.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 compile-time:01 printf:01 printf:01 whould:01 expr:01 2005,:98 wrote:01 expression:01 expression:01 functions:01 jambon:01 jambon:01 string:03 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 On Mon, 15 Aug 2005, Dmitri Boulytchev wrote: > Hello everybody, > > I'm looking for the way to get string representation of the OCaml > expression > at compile-time to facilitate test writing. Consider an example: > > let repr, value = WITH_REPR (1+2) in > Printf.printf "%s=%d" repr value > > Here WITH_REPR is a meta-construction that returns ("1+2", 3) (generally > speaking WITH_REPR(c) whould return (string * type_of c)). > > Is there some convinient way to do this? May camlp4 help? Have a look at the pretty-printing functions that pr_o.ml provides (from your Camlp4 installation). You can probably hack your own (expr -> string) function if it does not already exist. Martin -- Martin Jambon, PhD http://martin.jambon.free.fr