Ashraya:

I'll try to summarize what's transpired in this thread.

You:
    "I am trying to use the C extention feature with perl6."

Sisyphus (maintainer of Inline::C):
    "I don't see how Inline::C (in its current form) could ever
     work with perl6 - because, under the hood, Inline::C
     does little more than write (and compile) an XS file."

Will:
    "This question is better sent to perl6-us...@perl.org -
     Inline::C doesn't exist in perl6, so even if you get past
     the error on the use statement, this isn't going to
     work as written."

You:
    "Can anyone please help with using inline C in perl6 ?"


Now I'll try to explain as clearly as I can.

Perl5's mechanism for interfacing C code with Perl is a hybrid
language called XS.  An extension written in XS gets compiled to C by
ExtUtils::ParseXS.  It is then compiled by a C compiler, linked to
whatever C libraries are needed (including some from the Perl
distribution), and then made available to Perl via some spooky code in
a module called XSLoader, or another one called Dynaloader.

Inline::C lets you write C code, which is then converted by Inline::C
to XS.  But from there, the same tools apply; ExtUtils::ParseXS, a C
compiler, and a loader such as Dynaloader.  To the Inline::C user,
most of these lower level steps are whitewashed so that you don't see
them up close.  But it's very important to keep in mind that XS is
Perl5's "extension language".  And Inline::C generates XS code.

Perl6 doesn't use XS as an extension language.  Therefore, the XS code
that Inline::C generates is utterly useless to Perl6.  Perl6 does not
work with Perl5's XS code.  Since that's what Inline generates, Perl6
doesn't work with Inline.  Nobody can help you with this; it's not
likely to ever change.

Whew, we got that out of the way.  Now what?

Well, your real problem is that you would like to interface some C
code with Perl 6.  Your mistake is thinking that Inline::C will get
you there.  It won't.  But there MAY be some mechanism available for
interfacing Perl 6 with C.  And the people who can help you with that
are the Perl 6 people, not the Inline people, as we're focused on a
tool that is only applicable to Perl5.

I'm not much of a Perl6 expert.  However, there are mailing lists
where Perl6 people participate, and you probably would get a more
definitive answer there.  Check out the Perl6-oriented lists at this
link:

http://lists.perl.org/all.html#p

It could be that their answer is "This doesn't exist yet."  Or maybe
they can say, "Oh yes, you can do that using XYZ."  But either way,
they are the ones who will know.




On Wed, Aug 7, 2013 at 8:24 AM, Ashraya <theemeralds...@gmail.com> wrote:
> Hello All,
>
> Can anyone please help with using inline C in perl6 ? basically I want C
> extensions in perl6.
>
> This is what I tried..
>
>
> h2xs -PAXn Math::Simple
>
> ashiva@ubuntu:~/Parrot/rakudo/
> Inline-0.44/Math-Simple$ cat math.pl
> #!/usr/bin/perl6
>
> use lib './lib/Math/.';
> use Math::Simple;
>
> print add(2, 3);
> print subtract(3, 2);
> ashiva@ubuntu:~/Parrot/rakudo/Inline-0.44/Math-Simple$
>
> ashiva@ubuntu:~/Parrot/rakudo/Inline-0.44/Math-Simple$ cat
> lib/Math/Simple.pm
> package Math::Simple;
> $VERSION = '1.23';
>
> use base 'Exporter';
> @EXPORT_OK = qw(add subtract);
> use strict;
>
> use Inline C => 'DATA',
>            VERSION => '1.23',
>            NAME => 'Math::Simple';
>
> 1;
>
> __DATA__
>
> =pod
>
> =cut
>
> __C__
> int add(int x, int y) {
>   return x + y;
> }
>
> int subtract(int x, int y) {
>   return x - y;
> }
>
>
> But I keep getting this error :
>
> ashiva@ubuntu:~/Parrot/rakudo/
> Inline-0.44/Math-Simple$ perl6 math.pl
> ===SORRY!===
> arglist case of use not yet implemented. Sorry.
> at math.pl:3
> ashiva@ubuntu:~/Parrot/rakudo/Inline-0.44/Math-Simple$
>
> Please help..
>
> Thanks & Regards,
> Ashiva
>
>
> Thanks & Regards,
> Ashraya S Shiva
>
>
> On Wed, Aug 7, 2013 at 6:15 PM, Will Coleda <w...@coleda.com> wrote:
>>
>> This question is better sent to perl6-us...@perl.org - Inline::C doesn't
>> exist in perl6, so even if you get past the error on the use statement, this
>> isn't going to work as written.
>>
>>
>>
>> On Wed, Aug 7, 2013 at 12:23 AM, Ashraya <theemeralds...@gmail.com> wrote:
>>>
>>> Hi All,
>>>
>>> I am trying to use the C extention feature with perl6. Although it worked
>>> fine with perl5, the C extention is different from perl5 to perl6. I tried
>>> to use the same as following :
>>>
>>> h2xs -PAXn Math::Simple
>>>
>>> ashiva@ubuntu:~/Parrot/rakudo/Inline-0.44/Math-Simple$ cat math.pl
>>> #!/usr/bin/perl6
>>>
>>> use lib './lib/Math/.';
>>> use Math::Simple;
>>>
>>> print add(2, 3);
>>> print subtract(3, 2);
>>> ashiva@ubuntu:~/Parrot/rakudo/Inline-0.44/Math-Simple$
>>>
>>> ashiva@ubuntu:~/Parrot/rakudo/Inline-0.44/Math-Simple$ cat
>>> lib/Math/Simple.pm
>>> package Math::Simple;
>>> $VERSION = '1.23';
>>>
>>> use base 'Exporter';
>>> @EXPORT_OK = qw(add subtract);
>>> use strict;
>>>
>>> use Inline C => 'DATA',
>>>            VERSION => '1.23',
>>>            NAME => 'Math::Simple';
>>>
>>> 1;
>>>
>>> __DATA__
>>>
>>> =pod
>>>
>>> =cut
>>>
>>> __C__
>>> int add(int x, int y) {
>>>   return x + y;
>>> }
>>>
>>> int subtract(int x, int y) {
>>>   return x - y;
>>> }
>>>
>>>
>>> But I keep getting this error :
>>>
>>> ashiva@ubuntu:~/Parrot/rakudo/Inline-0.44/Math-Simple$ perl6 math.pl
>>> ===SORRY!===
>>> arglist case of use not yet implemented. Sorry.
>>> at math.pl:3
>>> ashiva@ubuntu:~/Parrot/rakudo/Inline-0.44/Math-Simple$
>>>
>>> Does anyone know anything about it ?
>>>
>>> Please reply.
>>>
>>> Thanks & Regards,
>>> Ashraya S Shiva
>>
>>
>>
>>
>> --
>> Will "Coke" Coleda
>
>



-- 

David Oswald
daosw...@gmail.com

Reply via email to