Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi,
Inline::Perl5 is probably not the recommended entry point to perl6.
But it's, so far, the only aspect of perl6 I've come across that has piqued my interest in perl6 - and it looks like it's going to become *my* entry point (for that given reason).
Nevertheless, I'm happy to apologise for this unorthodoxy on my part if that's deemed appropriate.
(Blame Doug Hunt on the PDL mailing list for having mentioned Inline::Perl5 on the PDL-dev mailing list ;-)

So ... I have a perl5 module named Math::Float128. Basically, it does __float128 arithmetic, and it builds fine on most platforms if you use a recent port of the gcc compiler.
As an exercise, I thought it would be interesting (for me) to access that module and its functionality from perl6.
On Ubuntu 14.04 I have:
sisyphus@sisyphus5-desktop:~/p6$ perl6 -v This is Rakudo version 2015.12 built on MoarVM version 2015.12 implementing Perl 6.c. sisyphus@sisyphus5-desktop:~/p6$ perl -v This is perl 5, version 22, subversion 0 (v5.22.0) built for x86_64-li +nux ....
And, after muddling my way through the installation of Inline::Perl5 (with the assistance of a number of patient monks), I've come up with this perl6 script (which works fine):
use Inline::Perl5; my $p5 = Inline::Perl5.new; $p5.use('Math::Float128'); my $f128 = $p5.invoke('Math::Float128', 'new', '1.2345'); say "$f128"; $f128.print; say ''; # insert the newline say "ok";
That correctly outputs:
sisyphus@sisyphus5-desktop:~/p6$ perl6 use.pl 1.23450000000000000000000000000000009e+00 1.23450000000000000000000000000000009e+00 ok
Based on that it seems to me that the perl5 overloading of "" is being correctly accessed - as that's the only way I can think of that both

say "$f128";
and
$f128.print;

would render correctly.

Is that assessment correct ? (That's my first question).

Inspired by the success of

$f128.print;
I tried
$f128.say;

But that just outputs:
Inline::Perl5::Perl5Object.new(ptr => NativeCall::Types::Pointer.new(1 +00938200), perl5 => Inline::Perl5.new)
Why ? (That's my second question).

Is there a better way to access __float128 arithmetic using perl6 ? (My third and last question ... for tonight ;-)

Cheers,
Rob

In reply to [perl6] More Inline::Perl5 musings by syphilis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-23 06:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found