From: Jos Backus <jos@catnook.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension (UPDATE)
Date: Thu, 2 Aug 2007 11:54:37 -0700 [thread overview]
Message-ID: <20070802185437.GB41396@lizzy.catnook.local> (raw)
In-Reply-To: <20070802095857.GD21868@tux-chan>
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
next prev parent reply other threads:[~2007-08-02 18:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-01 4:01 undefined symbol `caml_tuplify2' in dynamic rocaml extension Jos Backus
2007-08-01 7:44 ` [Caml-list] " Julien Moutinho
2007-08-01 9:43 ` Mauricio Fernandez
2007-08-01 13:59 ` Gordon Henriksen
2007-08-01 9:16 ` Mauricio Fernandez
2007-08-01 16:17 ` Jos Backus
2007-08-01 17:59 ` Jos Backus
2007-08-01 23:24 ` [Caml-list] undefined symbol `caml_tuplify2' in dynamic rocaml extension (UPDATE) Jos Backus
2007-08-02 9:20 ` Mauricio Fernandez
2007-08-02 9:58 ` Mauricio Fernandez
2007-08-02 18:54 ` Jos Backus [this message]
2007-08-02 18:58 ` Jos Backus
2007-08-01 23:34 ` rocaml bug + fix Jos Backus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070802185437.GB41396@lizzy.catnook.local \
--to=jos@catnook.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox