FFI::P...unction(3pm)
π¦ NAME π¦
Okay so bestie, FFI::Platypus::Function is literally an FFI function object β that's the whole vibe. It's the class that holds onto a platypus function for you. Iconic. π
(this page lives in the User Contributed Perl Documentation manual, section 3pm, just so you know where you're standing π«Ά)
β¨ VERSION β¨
version 2.11 β that's the one, no cap.
π SYNOPSIS π
use FFI::Platypus 2.00;
# call directly
my $ffi = FFI::Platypus->new( api => 2 );
my $f = $ffi->function(puts => ['string'] => 'int');
$f->call("hello there");
# attach as xsub and call (faster for repeated calls)
$f->attach('puts');
puts('hello there');
See how we did it twice? First one is the direct-call era, second one is the attached-as-xsub era where repeated calls go zoom. ποΈβ¨
πΈ DESCRIPTION πΈ
So this class represents an unattached platypus function. That's the whole thing. If you want more context and honestly better examples, go read FFI::Platypus β it's the main character, this page is the spin-off. π
π METHODS π
π attach
$f->attach($name);
$f->attach($name, $prototype);
Attaches the function as an xsub β basically the same energy as calling attach straight from an FFI::Platypus instance. And you may optionally include a prototype if you're feeling fancy. β
π call
my $ret = $f->call(@arguments);
my $ret = $f->(@arguments);
Calls the function and hands you back the result. And here's the cute part β you can also use the function object like a code reference. Same thing, different outfit. π
π§ sub_ref
my $code = $f->sub_ref;
Returns an anonymous code reference. And ngl, this will usually be faster than using the call method above. Lowkey the upgrade you didn't know you needed. π₯
π AUTHOR π
Author: Graham Ollis <plicease@cpan.org>
Contributors β the whole squad, give them their flowers π:
- Bakkiaraj Murugesan (bakkiaraj)
- Dylan Cali (calid)
- pipcet
- Zaki Mughal (zmughal)
- Fitz Elliott (felliott)
- Vickenty Fesunov (vyf)
- Gregor Herrmann (gregoa)
- Shlomi Fish (shlomif)
- Damyan Ivanov
- Ilya Pavlov (Ilya33)
- Petr PΓsaΕ (ppisar)
- Mohammad S Anwar (MANWAR)
- HΓ₯kon HΓ¦gland (hakonhagland, HAKONH)
- Meredith (merrilymeredith, MHOWARD)
- Diab Jerius (DJERIUS)
- Eric Brine (IKEGAMI)
- szTheory
- JosΓ© JoaquΓn Atria (JJATRIA)
- Pete Houston (openstrike, HOUSTON)
- Lukas Mai (MAUKE)
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2015-2022 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. So yes, go off, just respect the terms fr fr. π
Quick vibe check before you go:attachit if you're calling a million times,sub_refif you want speed, plaincallif you're just chilling. All valid, all slay. π
And that's a wrap, bestie! This was FFI::P...unction(3pm) from perl v5.42.3, dated 2026-08-20 β mwah, go write some bindings π«Άβ¨π¦
π¦ where this page comes from
- ubuntu stonking: libffi-platypus-perl 2.11-1build1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms