[Xapian-devel] ExpandDecider and MatchDecider operator() return type

Olly Betts olly at survex.com
Fri Apr 20 01:58:43 BST 2007


Currently ExpandDecider::operator() and MatchDecider::operator() return
`int' for no very good reason that I can see.  It would be more natural to
return `bool', since these classes are making a "yes/no" decision about
whether to include a term in an ESet or a document in an MSet.

The problem is that this can't be done without breaking existing user
code which defines subclasses of MatchDecider or ExpandDecider (or at
least I can't see a way since C++ overloading is based on the argument
types only, not the return type).

So previously I've just ignored this, but it's now giving me grief while
trying to create SWIG based Java bindings which are as compatible as
possible with the existing hand-written JNI Java bindings.

I propose this should change in 1.0.  We'll have to skip deprecating the
old way, but updating is easy (just change 'int' to 'bool') and any
existing code which needs changing will give a pretty clear error, e.g.
GCC 4.1 reports:

    error: conflicting return type specified for 'virtual int
	Xapian::MyExpandDecider::operator()(const std::string&) const'
    error:   overriding 'virtual bool
	Xapian::ExpandDecider::operator()(const std::string&) const'

Thoughts?

Cheers,
    Olly



More information about the Xapian-devel mailing list