Version française
Home     About     Download     Resources     Contact us    
Browse thread
CamlP4 and Threads
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Martin Jambon <martin.jambon@e...>
Subject: Re: [Caml-list] CamlP4 and Threads
On Sat, 27 Jan 2007, Jonathan Bryant wrote:

> I'm think I'm finally understanding CamlP4 and I'm trying to make a small 
> syntax extension using it, but I can't find the rule I need to extend.  I 
> want to turn this:
>
> let f x y x = ....
> let x = |f| x y z
>
> into this:
>
> let f x y z = ...
> let x =
> let c = Event.new_channel () in
> let _ = Thread.create (fun c -> let x = f x y z in Event.sync (Event.send c 
> x)) in
> Event.receive c
>
> but, like I said, I can't seem to find the rule I need to extend.  I can do 
> it for an arbitrary expression:
>
> let x = |3 + 5|
>
> to
>
> let x =
> let c = Event.new_channel () in
> let _ = Thread.create (fun c -> let x = 3 + 5 in Event.sync (Event.send c 
> x)) in
> Event.receive c
>
> just not function application.
>
> I've tried extending Pcaml.expr's "apply" but that doesn't seem to work, and 
> I can't see any other place to do it.

You have to create a rule for your special function application, e.g.

   "|"; f = expr; "|"; args = LIST0 expr LEVEL "." -> ...

Is it what you tried?


Martin

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