Hi all, here is what i did:

package Karl::Fractals::Mandelbrot; use Moo; use strictures 1; use namespace::clean; use Inline C => 'DATA'; sub reckon { my ( $self, $x, $y ) = @_; mandelbrot( $x, $y ); } has iterations => ( is => 'ro', default => 20 ); has width => ( is => 'ro', default => 1280 ); has height => ( is => 'ro', default => 1024 ); 1; __DATA__ __C__ /* fake */ int mandelbrot(int x, int y) { return x*y; }

 

#!/usr/bin/env perl use strict; use warnings; use lib q(.); use Karl::Fractals::Mandelbrot; use feature qw (say); use Data::Dump; my $Benoit = Karl::Fractals::Mandelbrot->new(); dd $Benoit; say $Benoit->reckon( 2, 7 ); __END__ karls-mac-mini:monks karl$ ./inline_moo.pl bless({ height => 1024, iterations => 20, width => 1280 }, "Karl::Frac +tals::Mandelbrot") 1280 1024 20 14

Somehow related to some of my previous posts.

This very simplified example works as expected.

But i wonder if it is good practice. Perhaps some unexpected traps?

BTW, I didn't use Inline::C except for "Hello World!" until now.

Thank you very much for any hint and best regards, Karl

«The Crux of the Biscuit is the Apostrophe»


In reply to About Moo and Inline::C by karlgoethebier

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.