On 04/12/2014 22:27, Marvin Humphrey wrote:
From C-space, we only need something we can invoke Clownfish-style methods on.
It's easy to generate a Clownfish wrapper around any kind of Perl object to
achieve that.
That's what `HostTransformer` in my example is for.
I have to admit that I don't understand everything about the proposal. I
guess you need need a separate Transformer class because you want to exclude
concrete methods on Analyzer like Transform_Text()?
Yes.
In any case, I hope that the eventual goal is to support stuff like this:
package DummyAnalyzer;
sub new { return bless {}, __PACKAGE__ }
sub transform {
my ($self, $batch) = @_;
return $batch;
}
sub dump { return { _class => __PACKAGE} }
sub load { return __PACKAGE__->new() }
package main;
my $type = Lucy::Plan::FullTextType->new(
analyzer => DummyAnalyzer->new,
);
Note that DummyAnalyzer...
* is implemented as a blessed hash
* does not have "Lucy::Analysis::Analyzer" in @ISA
* does not call SUPER::new
* does not implement DESTROY
Yes, that's the goal.
Right now, if we supply DummyAnalyzer object as an argument to FullTextType's
constructor, we'll get an exception because DummyAnalyzer does not inherit
from Analyzer. But what we could do instead is wrap the blessed hash in a
Clownfish object which knows how to call back into Perl for each method.
Yes, the wrapper is `HostTransformer`.
Nick