Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] camlp4 and let binding...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: [Caml-list] camlp4 and let binding...

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 inside (like in your example), you have to
make the variable "definition" a list of (patt * expr) and you can

            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:

            value $lid:pref$ =
              let $p1$ = $e1$
              and $p2$ = $e2$ in
              new rule(pattern,action)

If you prefer a " let.. in" instead of "let .. and .. in", you
have to write it explicitely:

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

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: