Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Add Perl examples #103

wants to merge 3 commits into from

Conversation

plicease
Copy link

@plicease plicease commented May 2, 2021

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:

Reading state information...
E: Version '14.12.*' for 'nodejs' was not found
The command 'bash -c apt-get update                 && apt-get install -y         build-essential         clang         curl         software-properties-common                 && add-apt-repository -y ppa:deadsnakes/ppa         && add-apt-repository -y ppa:brightbox/ruby-ng         && add-apt-repository -y ppa:hvr/ghc         && curl -sL https://deb.nodesource.com/setup_14.x | bash -         && apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF         && echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | tee /etc/apt/sources.list.d/mono-official-stable.list         && apt-get update                 && apt-get install -y         ghc-8.8.1         mono-devel='6.12.*'         nodejs='14.12.*'         python3.8         ruby2.7         ruby2.7-dev         perl         cpanminus                 && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100

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.

@@ -0,0 +1,13 @@
use strict;
use warnings;
use 5.010;
Copy link
Author

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"

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 {
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants