Mailing List Archive

%FIELDS changes to %fields
Greets,

The %FIELDS hash has been lowercased. As of repository revision
2382, it is spelled %fields.

our %fields = (
title => 'KinoSearch::Schema::FieldSpec',
content => 'KinoSearch::Schema::FieldSpec',
);

This change is forced by an implementation of 'fields' and 'base'
pragmas in Perl. fields.pm reserves the %FIELDS hash for storing its
own data, and 'base' propagates that data. This common idiom...

use base qw( Foo );

... does more than just manipulate @ISA. Snoop base.pm if you're
morbidly curious.

In theory, we could indicate that 'base' should not be used to
manipulate inheritance, and that direct manipulation of @ISA should
be used instead:

package MySchema;
use KinoSearch::Schema;
our @ISA = qw( KinoSearch::Schema );

sub analyzer { ... }

... However, that would be poor API design, since 'use base' is
ubiquitous these days and we can predict that at least some
percentage of users will make an 'error'.

The problem came to my attention when I tried to subclass a subclass
of Schema. base.pm attempted to propagate %FIELDS, but it didn't
work correctly because my hand-rolled %FIELDS hash didn't look like
the kooky pseudohash that fields.pm would have produced, and Perl
gave me this warning:

t/212-multi_posting_list......ok
t/213-segment_merging.........Argument
"KinoSearch::Schema::FieldSpec" isn't numeric in array element at /
System/Library/Perl/5.8.6/base.pm line 146.
t/213-segment_merging.........ok
t/214-spec_field..............ok

Marvin Humphrey
Rectangular Research
http://www.rectangular.com/