From: Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] camlp4 and let binding...
Date: Tue, 26 Nov 2002 12:56:10 +0100 [thread overview]
Message-ID: <20021126125610.D8318@verdot.inria.fr> (raw)
In-Reply-To: <20021126042909.GD29607@zed>; from Pietro.Abate@anu.edu.au on Tue, Nov 26, 2002 at 03:29:09PM +1100
Hi,
On Tue, Nov 26, 2002 at 03:29:09PM +1100, Pietro Abate wrote:
>
> I wrote something that, of course, doesn't work. My major problems are about
> the inner let definitions. How can I chain all let defintions in the list ?
I am not sure I understand what you want to do but this:
> <str_item:<
> value $lid:pref$ = $list:definition$ in
> new rule(pattern,action)
> >>
is syntactically incorrect: you must not put "in" after a "value". If
you want to make a let..in inside (like in your example), you have to
make the variable "definition" a list of (patt * expr) and you can
write:
<str_item:<
value $lid:pref$ =
let $list:definition$ in
new rule(pattern,action)
>>
If "definition" is, for example, the list: [(p1, e1); (p2; e2)] it is
equivalent to:
<str_item:<
value $lid:pref$ =
let $p1$ = $e1$
and $p2$ = $e2$ in
new rule(pattern,action)
>>
If you prefer a "let..in let.. in" instead of "let .. and .. in", you
have to write it explicitely:
<str_item:<
value $lid:pref$ =
let $p1$ = $e1$ in
let $p2$ = $e2$ in
new rule(pattern,action)
>>
If you want that, but you have a list of let..in with an unknown
number of elements, you have to do it with an iterator, e.g.:
List.fold_right (fun (p1, e1) e -> <:expr< let $p1$ = $e1$ in $e$ >>)
list <:expr< new rule(pattern, action) >>
--
Daniel de RAUGLAUDRE
http://cristal.inria.fr/~ddr/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2002-11-26 11:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-26 4:29 Pietro Abate
2002-11-26 11:56 ` Daniel de Rauglaudre [this message]
-- strict thread matches above, loose matches on Subject: below --
2002-11-26 0:07 Pietro Abate
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=20021126125610.D8318@verdot.inria.fr \
--to=daniel.de_rauglaudre@inria.fr \
--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