From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id B98BDBC0B for ; Sun, 28 Jan 2007 00:22:35 +0100 (CET) Received: from sccmmhc92.asp.att.net (sccmmhc92.asp.att.net [204.127.203.212]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l0RNMeT5016527 for ; Sun, 28 Jan 2007 00:22:41 +0100 Received: from [192.168.0.104] (12-208-241-105.client.mchsi.com[12.208.241.105]) by sccmmhc92.asp.att.net (sccmmhc92) with SMTP id <20070127232233m9200jfqd8e>; Sat, 27 Jan 2007 23:22:33 +0000 Mime-Version: 1.0 (Apple Message framework v752.3) Content-Transfer-Encoding: 7bit Message-Id: Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed To: caml-list@yquem.inria.fr From: Jonathan Bryant Subject: CamlP4 and Threads Date: Sat, 27 Jan 2007 18:21:39 -0500 X-Mailer: Apple Mail (2.752.3) X-Miltered: at concorde with ID 45BBDEC0.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 threads:01 camlp:01 syntax:01 pcaml:01 threads:01 gced:01 ocaml:01 bug:01 arbitrary:01 workaround:01 expression:02 scope:03 seems:03 module:03 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. Also, it seems that the implementation of the Event module has an error: the above code causes a space leak if x is not synchronized upon. In CML (the basis for the Event module), threads are GCed when they go out of scope, so this is not a problem. As a matter of fact, it is cited as the way to go about things. But since OCaml doesn't GC threads, this is a problem. Does anyone know of a workaround for this? And/or should it be submitted as a bug report? --Jonathan Bryant