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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |