-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Perl examples #103
base: master
Are you sure you want to change the base?
Add Perl examples #103
Conversation
@@ -0,0 +1,13 @@ | |||
use strict; | |||
use warnings; | |||
use 5.010; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the examples require Perl 5.10 feature of say
which makes the code more like the other languages and easier to read without having to us print
and explicitly put an "\n"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
$ffi->find_lib( lib => 'objects' ); | ||
$ffi->load_custom_type('::PtrObject' => 'ZipCodeDatabase' => 'ZipCodeDatabase' ); | ||
|
||
package ZipCodeDatabase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Examples with a package inside of them use the package block syntax for readability. This requires Perl 5.14, which was first released in 2011. It might make sense for all of the examples to require the same version, but I've only specified versions where I need say
and the package block syntax, and just the minimum perl required for each example.
This should address #55. This adds Perl examples to everything except
vector_return
which doesn't appear to have a page yet. It does not yet include the prose section for each example file, but I do plan on writing this as well. I was able to test the examples locally, but when I tried to build the docker image I got a diagnostic that I believe is unrelated to this PR:I think this is probably related the the version of node being specified in the Dockerfile.
The Perl library
FFI::Platypus
includes a language plugin for rust: https://metacpan.org/pod/FFI::Platypus::Lang::Rust which includes documentation for Perl programmers wanting to call Rust from Perl. It might be worth linking to, though I am not sure where is the right place. Perhaps in the integer prose section, since that is the example most people will see first.