[Xapian-discuss] PHP bindings
Samuel Liddicott
sam@liddicott.com
Wed, 26 May 2004 14:46:07 +0100
Foolish me, I knew all that.
No, really!
I thing this is something that ought to be fixed in the swig php module, but
even that would be a hack workaround broken php4.
Php5 supports namespaces natively, like perl.
But that would still need updates to the php swig module.
Sam
----- Original Message -----
From: "Olly Betts" <olly@survex.com>
To: "Samuel Liddicott" <sam@liddicott.com>
Cc: "James Aylett" <james-xapian@tartarus.org>;
<xapian-discuss@lists.xapian.org>
Sent: Wednesday, May 26, 2004 2:26 PM
Subject: Re: [Xapian-discuss] PHP bindings
> On Wed, May 26, 2004 at 11:14:04AM +0100, Sam Liddicott wrote:
> > I'm pretty sure all the xapian object methods are implemented as php
object
> > methods not global classless methods.
> >
> > So Xapian::Auto::open should only work as a method of Xapian_Auto or
maybe
> > Auto.
>
> Xapian::Auto is a namespace, not a class. Xapian::Auto::open is a
> function not a method (it's a factory function which returns a new
> Xapian::Database or Xapian::WritableDatabase object - if you're not
> familiar with the idea, think of it as an out-of-class constructor).
>
> A reason for the factory functions is so that backends can be added
> without changing the API of the database classes (although now I come
> to think about it, the Auto pseudo-backend could be implemented as a
> static method of the database class - but that still leaves the backend
> specific factory functions, like Xapian::InMemory::open). The eventual
> aim is to allow backends to be implementable by the user (much as
> weighting schemes can already be).
>
> Methods of classes do get a prefix (though it's database_ not
> xapian_database which may not be to some people's taste - names like
> database_ and document_ are very generic and likely to be used by
> other libraries).
>
> C++ allows you to choose - you can "use namespace Xapian;" or "use
> Xapian::Database;" if you wish. You can even alias a shorter name
> to Xapian. Perl allows at least the first two. The problem with
> using a prefix as a pseudo-namespace is that there's no language
> support for importing names from it.
>
> Cheers,
> Olly
>
>