Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: tmp123 <tmp123@menta.net>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Which camlp variant?
Date: Fri, 09 Nov 2007 11:34:51 +0000	[thread overview]
Message-ID: <473445DB.20807@menta.net> (raw)
In-Reply-To: <4a051d930711071716n7c88dde9t7dfe4c190ea3a90d@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2345 bytes --]

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
>>>
>>>
>>>      
>>>
>
>  
>


[-- Attachment #2: Type: text/html, Size: 3693 bytes --]

      parent reply	other threads:[~2007-11-09 10:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-07 18:25 tmp123
2007-11-07 18:20 ` [Caml-list] " Martin Jambon
2007-11-08  0:24 ` Nicolas Pouillard
2007-11-08  0:48 ` Christopher L Conway
     [not found]   ` <4a051d930711071716n7c88dde9t7dfe4c190ea3a90d@mail.gmail.com>
2007-11-09 11:34     ` tmp123 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=473445DB.20807@menta.net \
    --to=tmp123@menta.net \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox