Calling functions whose signature/arguments are only known at runtime

0 views
Skip to first unread message

Jonathan Leto

unread,
Mar 16, 2010, 3:03:59 PM3/16/10
to parrot-dev, plpa...@googlegroups.com
Howdy,

Recently on #parrot, eggyknap++ asked this question:

<eggyknap> davidfetter and I are embedding parrot in postgresql, and
are under the impression we should use Parrot_ext_call(). The problem
is that requires us to know at compile time the functions arguments,
which we can't do.
<Coke> davidfetter: ... can't you just dynamically construct the
signature string?
<eggyknap> The signature string is easy. But the arguments themselves
aren't. Parrot_ext_call() takes a signature string and a varargs list
of arguments
...
<Coke> eggyknap: I wonder if we could take a container PMC or
something and let you use :flat.

After doing a little research, it seems that plobsing++'s work on the
Parrot_ext_call_cb function in the tt1477 branch is what we need [0],
but I would like to be sure and ask for additional comments about the
best way to go about this. We want a solution that will work for
stored procedures written in any language sitting on top of Parrot,
not just PIR, but for the time being, we are more than happy to get
just PIR working.

Your comments and constructive criticism would be greatly appreciated.

Duke

[0] http://github.com/leto/parrot/commit/8e0861f98c943bcd64d3563362085c0c68aac40e

--
Jonathan "Duke" Leto
jona...@leto.net
http://leto.net

Jonathan Leto

unread,
Mar 16, 2010, 3:53:13 PM3/16/10
to Andrew Whitworth, parrot-dev, plpa...@googlegroups.com
Howdy,

On Tue, Mar 16, 2010 at 12:19 PM, Andrew Whitworth
<wknig...@gmail.com> wrote:
> My initial thought, and this isn't implemented quite yet (though we
> could put the fire back to my feet to complete it) is to create a
> CallContext PMC with all the arguments you want and pass that in.

This sounds interesting, what do we get if we go this route? Does it
make certain things easier/faster/more portable?

>
> Putting arguments into a ResizablePMCArray or Hash and using :flat
> (Signature "Pf") would similarly resolve the problem.

Good idea! I think that we could make stuff work at the PIR level
going that route, but I don't think HLL's would work using that
method. But it gives us a path forward, which is very good. I still
think that Parrot_ext_call_cb is going to be the way to get HLL
argument passing working correctly, perhaps wrapped in some kind of
container PMC.

Duke

Reply all
Reply to author
Forward
0 new messages