Version française
Home     About     Download     Resources     Contact us    
Browse thread
undefined symbol `caml_tuplify2' in dynamic rocaml extension
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Mauricio Fernandez <mfp@a...>
Subject: Re: [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension (UPDATE)
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. 

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.

-- 
Mauricio Fernandez  -   http://eigenclass.org