Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Hugo Ferreira <hmf@inescporto.pt>
To: caml-list@yquem.inria.fr
Subject: camlp4: let binding
Date: Thu, 05 Apr 2007 11:59:11 +0100	[thread overview]
Message-ID: <4614D67F.1010702@inescporto.pt> (raw)

Hello,

I would like to use a reserved word and substitute that by a function
call. For example, the following:

let  _ = HEAP in
let h1 = HEAP in

would become

let __heap = new_heap () in
let     h1 = new_heap () in

To do this I attempted (here I am not checking the identifier name):

   binding: [
    [ v = LIDENT ; "=" ; "HEAP" -> <:expr<$lid:v$ = new_heap ()>> ]
] ;

My problem however is how to activate the rule above? I figured I need
something like:

    Pcaml.str_item : LEVEL "top" [
          [ "let"; OPT "rec";
          l = LIST1 binding SEP "and" ; "in" ->
                          <str_item:< declare $list:l$ end>>
            ]
    ];

But this doesn't even compile. I then concentrated on using Pcaml's
let_binding function and see If I could simply reconstruct the
structured expression but failed. I also tried:

    Pcaml.expr: LEVEL "expr1"  [
      [
     "let"; l = LIST1 Pcaml.let_binding SEP "and" ; "in" -> <:expr<$l$>>

Here I get the error:
This expression has type (MLast.patt * MLast.expr) list
but is here used with type MLast.expr

Now I realize that my problem is (re)constructing the expression of a
let binding. I have been at this since yesterday and cannot find a
solution. Does anyone have an example of how to do this?


TIA,
Hugo Ferreira.





                 reply	other threads:[~2007-04-05 11:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4614D67F.1010702@inescporto.pt \
    --to=hmf@inescporto.pt \
    --cc=caml-list@yquem.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