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: Martin Jambon <mjambon@b...>
Subject: Re: [Caml-list] revised syntax and immediate objects
On Wed, 5 Jul 2006, Jonathan Roewen wrote:

> Hi,
>
> What is the syntax for immediate objects in ocaml when using revised syntax?
>
> 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>;
>
> I'd like to try make a camlp4 syntax extension that uses immediate
> objects, and this isn't helping ;-)

As far as I can tell, the syntax is the same as in class_expr:

$ cat toto.ml
Ocaml.revised := true
--
value o = object method hello = print_endline "Hello"; end
;

o#hello
;

$ ocamlscript toto.ml
Hello


Martin

--
Martin Jambon, PhD
http://martin.jambon.free.fr

Sandy: "Don't you have to be stupid somewhere else?"
Patrick: "Not until four."