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 52AD9BC69 for ; Thu, 2 Aug 2007 20:54:24 +0200 (CEST) Received: from lizzy.dyndns.org (209-204-188-132.dsl.static.sonic.net [209.204.188.132]) by concorde.inria.fr (8.13.6/8.13.6) with SMTP id l72IsKOS016914 for ; Thu, 2 Aug 2007 20:54:22 +0200 Received: (qmail 41476 invoked by uid 1000); 2 Aug 2007 18:54:37 -0000 Date: Thu, 2 Aug 2007 11:54:37 -0700 From: Jos Backus To: caml-list@inria.fr Subject: Re: [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension (UPDATE) Message-ID: <20070802185437.GB41396@lizzy.catnook.local> Reply-To: jos@catnook.com References: <20070801040102.GA88101@lizzy.catnook.local> <20070801091647.GB31718@tux-chan> <20070801161702.GA28680@lizzy.catnook.local> <20070801175907.GA29353@lizzy.catnook.local> <20070801232405.GB29353@lizzy.catnook.local> <20070802092050.GC21868@tux-chan> <20070802095857.GD21868@tux-chan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070802095857.GD21868@tux-chan> User-Agent: Mutt/1.5.16 (2007-06-09) X-Miltered: at concorde with ID 46B2285C.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; 0200,:01 0200,:01 val:01 segfaults:01 compile-time:01 foo:01 recursive:01 def:01 foo:01 ctxt:98 ctxt:98 wrote:01 wrote:01 abstract:01 caml-list:01 On Thu, Aug 02, 2007 at 11:58:57AM +0200, Mauricio Fernandez wrote: > On Thu, Aug 02, 2007 at 11:20:50AM +0200, Mauricio Fernandez wrote: > > > It looks like we are really close. The next (final?) issue is that we have a > > > function with signature > > > > > > val eval : kpp -> string -> value list -> value list > > > > > > where > > > > > > type value = > > > | Vstr of string > > > | Vtup of value list > > > > > > which we want to export to Ruby. We tried: > > > > > > Interface.generate(EXT_NAME) do > > > value = sym_variant("value") do |t| > > > non_constant :Vstr, STRING > > > non_constant :Vtup, LIST(t) > > > end > > [...] > > > but it doesn't work (it segfaults inside the extension). > > > > > > How does one represent `value' on the Ruby side? > > > > I think you have to wrap the LIST(t) in a TUPLE(): > > > > value = sym_variant("value") do |t| > > non_constant :Vstr, STRING > > non_constant :Vtup, TUPLE(LIST(t)) > > end > > > > I'll try to either auto-detect this or perform a compile-time check. > > Ignore that; I forgot that rocaml already detects when such extra boxing is > needed and performs it automatically, so non_constant :Vtup, LIST(foo) > should work already. It can't be due to the type being recursive either > because that works fine in the tree example. Thanks. We ended up doing Interface.generate(EXT_NAME) do kpp_value_t = sym_variant("kpp_value_t") do |t| non_constant :Vstr, STRING non_constant :Vtup, LIST(t) end def_class("KPP") do |c| t = c.abstract_type ctxt = LIST(kpp_value_t) fun "make", STRING => t method "eval", [t, STRING, ctxt] => ctxt ... end end so we can say kpp.eval("", [[:Vstr, "woot!"]]) > Just to make sure, are you calling eval as in > > kpp.eval(str, [[[ :Vtup, [ [[:Vstr, "foo"]] ] ]]]) > > The outer pair of [ ] because it's a block, the next one because it holds a > LIST, then the block represented as [symbol, value] where value is a block > holding a list of [symbol, value] blocks. > > If you've got the wrong number of [ ], maybe the generated extension isn't > detecting it, and hence the crash. > > Yes, it's hard to get the above right, so I'll see if something can be done > from Ruby to make it easier. That would be nice. Thanks for the explanation Mauricio. And thanks to everybody responding on this thread - it looks like we are all set now. -- Jos Backus jos at catnook.com