Re: Extending Moose with Inline C?

[email protected] ("Marco Fontani")
Newsgroups perl.moose
Message-ID <[email protected]>
> They build a hash with the parsed values -
> so using standard Perl OO I would just bless that hash and be done,
> but I guess in Moose that would not be that simple.

So you have your:

package A;

sub new {
  my $hashref = {};
  # do stuff to $hashref with Inline::C
  bless $hashref, 'Something';
}

You can just:

package Something:
# has '...' => (...);
# for each of the keys you may have on package A that you want to be
accessible from the Moose object
__PACKAGE__->meta->make_immutable();

and just change one line on your code:
-   bless $hashref, 'Something';
+  Something->new(%$hashref);

Definitely something easy to hack for you to check the following:

> Of course I don't know if the OO overhead will not spoil the
> advantage that we get from parsing in C - I'll have to verify
> that, I think this will depend much on the usage.

Cheers
~marco~
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.