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.6 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST,HTML_MESSAGE,MAILTO_TO_SPAM_ADDR autolearn=disabled version=3.1.3 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 4DBA1BC6B for ; Fri, 9 Nov 2007 11:40:25 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAABvHM0dA0DEbnmdsb2JhbACCcymLZQEBAQEHBAYpgQ8 X-IronPort-AV: E=Sophos;i="4.21,394,1188770400"; d="scan'208,217";a="4060751" Received: from discorde.inria.fr ([192.93.2.38]) by mail2-smtp-roc.national.inria.fr with ESMTP; 09 Nov 2007 11:40:25 +0100 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id lA9AeGqQ032529 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 9 Nov 2007 11:40:25 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAABvHM0dA0DEbnmdsb2JhbACCcymLZQEBAQEHBAYpgQ8 X-IronPort-AV: E=Sophos;i="4.21,394,1188770400"; d="scan'208,217";a="4060749" Received: from smail5.alcatel.fr ([64.208.49.27]) by mail2-smtp-roc.national.inria.fr with ESMTP; 09 Nov 2007 11:40:24 +0100 Received: from esmail03.netfr.alcatel.fr (esmail03.netfr.alcatel.fr [155.132.182.218]) by smail5.alcatel.fr (8.13.4/8.13.4/ICT) with ESMTP id lA9Ad7PK027066 for ; Fri, 9 Nov 2007 11:39:07 +0100 Received: from [159.23.98.76] ([159.23.98.76]) by esmail03.netfr.alcatel.fr (Lotus Domino Release 5.0.13aHF163) with ESMTP id 2007110911402153:592 ; Fri, 9 Nov 2007 11:40:21 +0100 Message-ID: <473445DB.20807@menta.net> Date: Fri, 09 Nov 2007 11:34:51 +0000 From: tmp123 User-Agent: Mozilla Thunderbird 0.9 (X11/20041105) X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: [Caml-list] Which camlp variant? References: <47320337.3030102@menta.net> <4a051d930711071648s593caaa5s3d6832e916d5a883@mail.gmail.com> <4a051d930711071716n7c88dde9t7dfe4c190ea3a90d@mail.gmail.com> In-Reply-To: <4a051d930711071716n7c88dde9t7dfe4c190ea3a90d@mail.gmail.com> X-MIMETrack: Itemize by SMTP Server on ESMAIL03/ES/ALCATEL(Release 5.0.13aHF163 | June 23, 2005) at 11/09/2007 11:40:21, Serialize by Router on ESMAIL03/ES/ALCATEL(Release 5.0.13aHF163 | June 23, 2005) at 11/09/2007 11:40:23, Serialize complete at 11/09/2007 11:40:23 Content-Type: multipart/alternative; boundary="------------020401030604000401020709" X-Scanned-By: MIMEDefang 2.51 on 155.132.188.13 X-Miltered: at discorde with ID 47343910.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 camlp:01 syntax:01 expr:01 expr:01 printf:01 lident:01 printf:01 val:01 stdout:01 syntax:01 val:01 beginner's:01 ocaml:01 bug:01 This is a multi-part message in MIME format. --------------020401030604000401020709 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1; format=flowed Thanks a lot, The solution from Chris covers all the requirements. A reduced subvariant of its "pa_log", compatible with camlp4 and adapted to this development has been written (probably with some errors ;-) open Camlp4.PreCast; open Syntax; (* Apply a function to a list of arguments *) value app_to_list lst _loc = List.fold_left (fun f x -> <:expr< $f$ $x$ >>) <:expr< Tools.log_printf >> lst; EXTEND Gram expr: LEVEL "apply" [ [ LIDENT "log"; e = LIST0 expr LEVEL "." -> <:expr< Tools.log_internal ( fun () -> $app_to_list e _loc$ ) >> ] ] ; END; It needs the support of a module "Tools" with two functions "log_internal" and "log_printf". By example: value log_active = ref False; value log_printf = Printf.printf; value log_internal e = if log_active.val then ( e(); print_newline(); flush stdout; ) else (); The syntax in the callers is: log "something is %d" 12; Thanks to all persons who has colaborate in this subject. ------------------------------------- Christopher L Conway wrote: >This may not have been true of the version that was on the website >previously. I've just updated it to my latest version, which does >indeed work with camlp5. > >Chris > >On Nov 7, 2007 7:48 PM, Christopher L Conway wrote: > > >>pa_log is compatible with camlp5. In fact, that's what I use. Just >>s/4/5/ all commands invoking camlp4. >> >>Regards >>Chris >> >> >>On Nov 7, 2007 1:25 PM, tmp123 wrote: >> >> >>>Hello, >>> >>>The module "pa_log" proposed by Mr. Conway seems very near to the >>>objective of my previuos post. >>> >>>The objective now is expand a line like: DEBUG 3 "%d\n" 14 >>>to: if debug.val then logint 3 ( fun () -> Printf.printf "%d\" 14 ) >>>else (); >>> >>>However, it is necessary to migrate the module to new camlpx . >>> >>>Please, could someone give any advice about the current options: camlp4 >>>or camlp5? PreCast? Functorial? >>> >>>Thanks a lot. >>> >>>_______________________________________________ >>>Caml-list mailing list. Subscription management: >>>http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list >>>Archives: http://caml.inria.fr >>>Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >>>Bug reports: http://caml.inria.fr/bin/caml-bugs >>> >>> >>> >>> > > > --------------020401030604000401020709 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=ISO-8859-1 Thanks a lot,

The solution from Chris covers all the requirements. A reduced subvariant of its "pa_log", compatible with camlp4 and adapted to this development has been written (probably with some errors ;-)

open Camlp4.PreCast;
open Syntax;

(* Apply a function to a list of arguments *)
value app_to_list lst _loc =
  List.fold_left
    (fun f x -> <:expr< $f$ $x$ >>)
    <:expr< Tools.log_printf >> lst;

EXTEND Gram

  expr: LEVEL "apply"
  [ [ LIDENT "log"; e = LIST0 expr LEVEL "." ->
        <:expr< Tools.log_internal ( fun () -> $app_to_list e _loc$ ) >>
       
  ] ]
;
END;



It needs the support of a module "Tools" with two functions "log_internal" and "log_printf". By example:

value log_active = ref False;

value log_printf = Printf.printf;

value log_internal e =
  if log_active.val then
  (
    e();
    print_newline();
    flush stdout;
  )
  else ();



The syntax in the callers is:

log "something is %d" 12;

Thanks to all persons who has colaborate in this subject.

-------------------------------------

Christopher L Conway wrote:
This may not have been true of the version that was on the website
previously. I've just updated it to my latest version, which does
indeed work with camlp5.

Chris

On Nov 7, 2007 7:48 PM, Christopher L Conway <cconway@cs.nyu.edu> wrote:
  
pa_log is compatible with camlp5. In fact, that's what I use. Just
s/4/5/ all commands invoking camlp4.

Regards
Chris


On Nov 7, 2007 1:25 PM, tmp123 <tmp123@menta.net> wrote:
    
Hello,

The module "pa_log" proposed by Mr. Conway seems very near to the
objective of my previuos post.

The objective  now is expand a line like: DEBUG 3 "%d\n" 14
to: if debug.val then logint 3 ( fun () -> Printf.printf "%d\" 14  )
else ();

However, it is necessary to migrate the module to new camlpx .

Please, could someone give any advice about the current options: camlp4
or camlp5? PreCast? Functorial?

Thanks a lot.

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


      

  

--------------020401030604000401020709--