Version française
Home     About     Download     Resources     Contact us    
Browse thread
Record types "with" syntax and camlp4
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas Pouillard <nicolas.pouillard@g...>
Subject: Re: [Caml-list] Record types "with" syntax and camlp4
On 2/21/07, Gabriel Kerneis <gabriel.kerneis@enst.fr> wrote:
> Hi,
>
> the { x with y = z} syntax seems to be broken in camlp4. But i can't
> find any information about it in the (deprecated ?) camlp4 manual.
>

Not br0ken, just different. For ambiguity reasons the expression
before "with" needs parentheses.

> 19:29 gabriel % cat record.ml
> type t = { a : int ; b : float } ;
> value x =
>   let s = {a=5 ; b= 1.5} in
>      {s with b = 4.1}  ;

{ (s) with b = 4.1 };

>
> 19:29 gabriel % camlp4rf record.ml
> File "record.ml", line 4, characters 8-12:
> Parse error: [fun_binding] expected after [label_longident] (in
> [label_expr])
> zsh: exit 2     camlp4rf record.ml
>
> Any hint ?

I can also give you a meta-hint for camlp4 stuffs and revised syntax:

$ camlp4o -printer r -str '{ s with foo = bar }'
{ (s) with  foo = bar; };

Camlp4 is a translator itself so if you now how to do some thing in
the original syntax you can learn the revised one by asking to Camlp4
itself.

Of course you can still ask questions on that list...

Regards,

-- 
Nicolas Pouillard