I think the return values from various methods in the MARC::Record distribution could 
be more "intuitive".
And also more consistent.

If we have a BAD record in $record and try to perform $record->field($tag) we get 0 in 
return.
But if you try $record->subfield($sub) we get undef.

I would rather prefer undef for both.


With the same BAD record we try $subfield = eval { 
$record->field($tag)->subfield($sub) }
This is the only case where we have to put the code in eval.
Should MARC:: take care of the eval for us? I am beginning to think so.


At the bottom of this we have the creation of the record.
What would we expect to get back from these?

my $record1 = MARC::Record->new_from_usmarc(  );
my $record2 = MARC::Record->new_from_usmarc( undef );
my $record3 = MARC::Record->new_from_usmarc( '' );
my $record4 = MARC::Record->new_from_usmarc( 'not a valid record' );

Currently they all provide us with a "broken" record object.
>From the three first I myself would prefer to get undef in return.
That is how MARC::Batch treats the records.

The $record4 is a bit more complicated.
We have to decide "what is a valid record in this context?"
The answer would be, I'd guess, if we can perform other methods on the object it is a 
"valid" record (so far).


Leif
======================================
Leif Andersson, Systems Librarian
Stockholm University Library
SE-106 91 Stockholm
SWEDEN
Phone : +46 8 162769  
Mobile: +46 70 6904281

Reply via email to