Browse thread
undefined symbol `caml_tuplify2' in dynamic rocaml extension
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jos Backus <jos@c...> |
| Subject: | Re: [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension (UPDATE) |
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