[Xapian-devel] ruby bindings odds and ends
Olly Betts
olly at survex.com
Thu May 11 00:05:25 BST 2006
In the Ruby bindings, set_X and get_X are renamed to remove the get/set,
so MSet::get_matches_estimated() becomes a read-only property (if I have
my terminology right) of the Ruby MSet class called matches_estimated.
This matches how a Ruby programmer would expect a class to be designed.
I was looking through the getters and setters list. I wonder if a few
entries shouldn't be there, (the comment says it was auto-generated, so
I'm guessing it currently simply includes every method matching set_* or
get_*).
The ones I'm thinking of are those set_ methods which don't take exactly
one parameter, and perhaps those get_ methods which take parameters.
For example, Enquire::set_sort_by_relevance doesn't take any parameters,
while Enquire::set_sort_by_value takes two (the second is optional,
but it allows you to reverse the sort order which is a common thing to
want to do). Neither of these methods is really a setter method in
the usual sense. They're just methods with names which happen to start
"set_".
But I'm no Ruby programmer so I don't feel qualified to make this call
myself...
I'm also wondering if we should avoid wrapping C++ methods which are
deprecated (since there's no previous version of the Ruby bindings to
remain compatible with and those methods will be removed at some point,
possibly in 1.0 which should happen fairly soon). This isn't a Ruby
specific thought - I think it makes sense generally.
And lastly, for most languages, there's an extra Enquire method -
get_matching_terms() which just returns the matching terms as a list or
array or similar. I'm not sure why this one case gets special treatment
really - I think it's mostly just a historical oddity.
Anyway, this wasn't being renamed (because it's not in the C++ header
I guess). I added a rename, but then it collides with a hand-coded
matching_terms in xapian.rb, so I've now disabled it for Ruby. It
seems rather superfluous given we wrap all iterators to produce an
array anyway.
Cheers,
Olly
More information about the Xapian-devel
mailing list