Perl 6 - the future is here, just unevenly distributed

IRC log for #native, 2016-05-31

| Channels | #native index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:45 plicease mohawk: Your NativeCall module looks pretty cool.
00:46 mohawk ha ha, thanks!
00:46 plicease have you tried it with callbacks?
00:47 mohawk no, what would that look like?
00:48 plicease https://metacpan.org/pod/distribution/FFI-Platypus/lib/FFI/Platypus/Type.pod#Closures
00:51 plicease not sure what it looks like in p6 or what it should look like in p5-NativeCall
00:52 plicease or maybe it just works.
00:54 mohawk maybe
00:54 mohawk i'm not quite sure what problem this would solve?
00:55 mohawk more specifically, i see NativeCall as being purely for perl->C calls, and this callback thing doesn't seem to add to that?
00:55 plicease for some c libraries you need to be able to set error handlers, etc.
00:56 plicease it is reasonable to not support it, there is a lot of utility in just being able to call C
00:58 mohawk that makes sense
00:58 mohawk well, let's leave it as on the notional to-do list :-)
01:00 mohawk i have the crazy idea of converting Gimp-Perl to use NativeCall
01:01 mohawk which would hopefully solve the problem of finding the gimb libs and headers to link to, on windows
01:03 plicease indeed.  It is interesting to apply these things to real libraries.  Trying to do libarchive with FFI::Raw is what drove Platypus
01:04 plicease anyway, I'm adding a See also from the platypus POD I might try it out this week.  I'm finally back from my trip.
01:05 mohawk grin
01:05 mohawk a "see also" link to NativeCall?
01:05 plicease https://github.com/plicease/FFI-Platypus/commit/a91992e80098cd31b987803dd0bf8e0c8c509a83
01:06 plicease FFI::Platypus POD has a (probably too long) list of everything FFI related that I was ever able to find on CPAN :)
01:06 mohawk cor!
01:07 plicease actually some stuff that isn't even on cpan either :P
01:07 plicease I think I got carried away.
01:09 plicease do you know what the minimum Perl requirement is?
01:09 mohawk for NC?
01:09 plicease yes.
01:09 mohawk i haven't thought about it, so no
01:09 mohawk given the small amount it does, it'll be same as platypus
11:31 plicease I just wasn't sure if subroutine attributes hadn't changed in Perl over time since 5.8.1 (oldest Perl supported by Platypus)
11:31 plicease it would be good to add a test or two so that cpantesters can give an idea of where it works in practice.
11:51 jberger If you need a callback, it could be the currently ignored body of the sub ;p
11:59 ashevchuk joined #native
12:15 ashevchuk joined #native
23:01 plicease I don't think NativeCall will work with callbacks, at least not with the way they are declared with Platypus at the moment.
23:01 plicease unless there is a way to specify parans in an attribute value.
23:02 plicease closure type is something like (int,int)->int
23:03 plicease so you'd need to be able to :Args((int,int)->int) ... and even if the parans worked, the comma would mess things up.
23:03 jberger no, I was suggesting using the declared function AS the callback
23:04 jberger since at the moment the declared function is just an empty {} which is replaced by the wrapped C call
23:05 plicease the issue isn't passing the callback in (that should already work), it is declaring it.
23:06 jberger I don't know what you mean
23:06 jberger you have $subref here: https://metacpan.org/source/ETJ/NativeCall-0.003/lib/NativeCall.pm#L44
23:06 jberger and it is never used again
23:07 jberger sub cdio_close_tray :Args(string, int) :Native(cdio) { 'this is the callback' }
23:08 plicease right, but you don't pass in the callback when you are declaring the function, you pass it in when you call it.
23:08 jberger ah, sorry
23:08 plicease like in this example
23:08 plicease https://metacpan.org/pod/FFI::Platypus::Type#Closures
23:08 jberger here I am seeing fun in the syntax and I'm ignoring the actual use-case
23:08 plicease this doesn't work : sub set_closure :Args((int)->int, int) :Native(./closure.so) :Returns(void) {}
23:09 jberger I was assuming it was a post C call "cleanup" function
23:09 jberger but I get it now
23:09 plicease I am totally okay with this limitation, I think it just needs a caveat.
23:09 jberger yeah
23:09 plicease if you need closures you can use the Platypus interface.

| Channels | #native index | Today | | Search | Google Search | Plain-Text | summary