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 1FC88BC69 for ; Mon, 11 Jun 2007 12:11:16 +0200 (CEST) Received: from out4.smtp.messagingengine.com (out4.smtp.messagingengine.com [66.111.4.28]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5BABFMB001044 for ; Mon, 11 Jun 2007 12:11:15 +0200 Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 62210A25; Mon, 11 Jun 2007 06:11:14 -0400 (EDT) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by compute1.internal (MEProxy); Mon, 11 Jun 2007 06:11:14 -0400 X-Sasl-enc: +JFXze+LQvmnKt3BIn8EqdN4cRanDcYbYkJK0hqXhuuf 1181556673 Received: from [192.168.1.10] (AMontsouris-753-1-1-122.w90-2.abo.wanadoo.fr [90.2.128.122]) by mail.messagingengine.com (Postfix) with ESMTP id 602D31075A; Mon, 11 Jun 2007 06:11:13 -0400 (EDT) Date: Mon, 11 Jun 2007 12:11:11 +0200 (CEST) From: Martin Jambon X-X-Sender: martin@martin.ec.wink.com To: Joel Reymont Cc: Jacques GARRIGUE , jtbryant@valdosta.edu, caml-list@yquem.inria.fr Subject: Re: [Caml-list] camlp4 and class introspection In-Reply-To: Message-ID: References: <7C9995D9-AC11-4E7C-8477-25CA4B88A0F4@gmail.com> <20070611.095835.2004157669.garrigue@math.nagoya-u.ac.jp> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Miltered: at concorde with ID 466D1FC3.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 camlp:01 mli:01 runtime:01 ocaml:01 ocaml:01 syntax:01 yaron:01 annotation:01 ocaml-like:01 2007,:98 2007,:98 outlet:98 outlet:98 wrote:01 On Mon, 11 Jun 2007, Joel Reymont wrote: > > On Jun 11, 2007, at 1:58 AM, Jacques GARRIGUE wrote: > >> Then you can use camlp4 to parse the .mli and generate the >> registration code to be included in the .ml file. > > Right. I want to parse the class definition to extract instance variable > types and method signatures. Then I can use this information to create calls > to the Objective-C runtime. > > If there's an instance variable of type "float outlet", for example, then > I'll know to strip outlet from OCaml code and to tell ObjC that it's an > outlet. The whole purpose is to be able to define ObjC classes in OCaml while > automatically creating the glue and bridging code. I see 2 main options: - parse type definitions in standard OCaml syntax (what Jacques suggested): you can use an external preprocessor, the program can be compiled independently from camlp4, and you would discard type definitions that can't be converted to Objective-C. Another advantage is that you could use other similar preprocessors to generate code for other purposes. - introduce a special kind of type definitions (like Yaron suggested), so that only these would generate Objective-C code. The big advantage is that you could add options. For example, if an OCaml type has 2 equivalents in Objective-C, you could add an annotation to choose which one to use. It makes OCaml-like type definitions, which usually do not cover all possible type definitions and are not compatible with standard OCaml. Martin