Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] revised syntax and immediate objects
[ 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@i...>
Subject: Re: [Caml-list] revised syntax and immediate objects
On 7/4/06, Jonathan Roewen <jonathan.roewen@gmail.com> wrote:
> Hi,
Hi,

>
> What is the syntax for immediate objects in ocaml when using revised syntax?
Yes, it's the same with mandatory semi-colons to separate class structure items.

The grammar rule: "object"; opt_class_self_patt; class_structure; "end"

>
> I was reading the camlp4 tutorial from the caml site, and the section
> on objects just directs users to use camlp4o pr_r.cmo to dump an
> example in revised syntax.
>
> The snippet of input code is thus:
>
> let obj a b c = object method a : int = a method b : string = b method
> c : string option = c end;;
>
> The output from camlp4o pr_r.cmo gives:
>
> value obj a b c =<pr_r: not impl: expr; tag = 25>;

Yes, you're facing a programming style driven by laziness, this case
is not implemented. Of course the new version of Camlp4 already in the
official development CVS no more follow this programming way.

Here is the result:

$ camlp4o -printer OCamlr -str 'let obj a b c = object method a : int
= a method b : string = b method c : string option = c end'
value obj a b c =
  object
    method a : int = a;
    method b : string = b;
    method c : option string = c;
  end;

>
> I'd like to try make a camlp4 syntax extension that uses immediate
> objects, and this isn't helping ;-)

I hope the new version will be more pleasant to use :)

-- 
Nicolas Pouillard