On Tue, 28 Oct 2003, Anuradha Ratnaweera wrote: > On Tue, 2003-10-28 at 19:26, Dan Sugalski wrote: > > On Tue, 28 Oct 2003, Anuradha Ratnaweera wrote: > > > > > 2. If the ansewr to 0 or 1 is "no", will there be another standard in > > > Perl 6? > > > > Yes. Whatever we do for Parrot. > > Thigs are getting clearer and more confusing ;-) > > I am still in the trying-to figure-out-what-the-hell-is-going-on-here > phase so please bear with me about the stupid questions ;-) > > Let me ask one more, and hopefully the last, question; a specific one > this time: > > Say, there is a C library x (libx.{so,a}) which defines a function foo() > which takes a single argument `struct bar'. The prototype of foo() is > defined in x.h as: > > foo(struct bar); > > Actual definition might be a typedef insted of struct bar itself, but > all the same. > > And struct bar has three members: int a, char *b and struct morebar *c. > > Now, if one wants to create a Perl[56] binding to the library x, s?he > will create a module X. A script would look like: > > use X; > > my %bar = (); > my %morebar = (); > > $morebar{key} = 10; > $morebar{value} = "ten"; > > $bar{a} = 10; > $bar{b} = 'bar b'; > $bar{c} = \%morebar; > > foo($bar); > > Now, what exactly is going to happen when it comes to the foo($bar) > call?
Whatever you want to have happen. There's not goign to be anything automatic happening here, and there's no lurking magic--if the interface code you've written handles the conversion right, then the conversion will happen, otherwise it won't. Now, you could certainly write a PMC class that behaves as a struct (and we'll likely provide one as part of the core distribution) and prototype foo() so that it only took things of type bar, and save yourself a lot of hassle (which is likely the route I'd take) but that's up to the person who wrote the interface library. Dan --------------------------------------"it's like this"------------------- Dan Sugalski even samurai [EMAIL PROTECTED] have teddy bears and even teddy bears get drunk