Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re^2: Concurrency in Perl 6

by raiph (Chaplain)
on Nov 06, 2013 at 17:10 UTC ( #1061446=note: print w/replies, xml ) Need Help??

in reply to Re: Concurrency in Perl 6
in thread Concurrency in Perl 6

AFAIK there's no XS with perl 6, so just *how* does one extend perl6 ?

The highest level sugar of all for extending P6 with code from other langs starts with a use some::module:from<otherlang> statement. For example that's how you call Java code.

I mean, if I find a really cool C library whose functionality I want to wrap, precisely how do I go about doing that ?

In an ideal world you'd use the above sugar. In the real world things aren't quite that simple (a long discussion about this today on #perl6).

Fortunately there's a really nice lower level interface called NativeCall (codename Zavolaj) so you use that instead.

Is the procedure well laid out in the perl 6 documentation ?

Imo the formal doc is weak. I recommend interested parties first focus on this Advent Calendar post from a couple years ago.

NB Right now you need to use Rakudo/Parrot to use NativeCall. (The final fixes for it on Rakudo/JVM are expected this month. My guess is that it'll be another few months before Rakudo/MoarVM catches up.)

Also note that some of the doc is ahead of implementation, some of it behind.

Is it a big learning curve ?

For a 60 second intro, see this short example.

I particularly like the way NativeCall supports use of P6's is repr trait to overlay P6 objects and C structs. This combines high performance (the same memory is used by both langs for fast and memory efficient execution) with coding convenience -- you just write ordinary object oriented Perl 6 code to read/write from/to a C Struct!

. o O ( "the celebrity tell-all of the Perl-6 cult?" )

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1061446]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2018-03-18 16:05 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (230 votes). Check out past polls.