[Kde-bindings] PerlQt4's namespaces

Arno Rehn arno at arnorehn.de
Tue Feb 2 13:33:30 UTC 2010


On Tuesday 02 February 2010 03:58:09 Chris Burel wrote:
> A while ago there was a debate about what to name the new Qt module.
> There were concerns raised about getting ownership of the Qt namespace
> in CPAN, as well as the namespace collision that would happen if
> someone wanted to have both the PerlQt3 module and the PerlQt4 module
> installed at the same time.  We did end up getting the CPAN namespace
> ownership (thanks Ashley!), but the latter concern led to the decision
> of naming the module Qt4.  Initially, I wanted to just rename the
> module, so you'd say 'use Qt4;' in the code, but the module would
> still populate the Qt namespace, so you'd have 'my $widget =
> Qt::Widget()'.  This wouldn't cause a runtime namespace collision,
> because while people may want to have both Qt3 and Qt4 Perl modules
> installed, they wouldn't be using both in the same application.  But
> there was concern about possible confusion between the name of the
> module and the namespace that it populates, so the decision was to
> keep the module name in sync with it's namespace.  So you'd have 'use
> Qt4; my $app = Qt4::Application(); my $widget = Qt4::Widget()'.
> 
> But now that the Smoke library is broken up, we're faced with breaking
> up the bindings into multiple Perl modules as well.  Presumably, these
> could be called either 'QtCore' and 'QtGui', or to be forward-looking,
> called 'QtCore4' and 'QtGui4'.  Keeping in line with the decision made
> earlier about keeping the module name in sync with the namespace it
> populates, that would mean your code now looks like this:
> use QtCore4;
> use QtGui4;
> my $app = QtGui4::Application(...);
> my $widget = QtGui4::Widget(...);
> # and, for example
> my $variant = QtCore4::Variant(...);
> 
> This seems really horrid to me, because now we're requiring the users
> of the bindings to know what module a given type comes from, and would
> get much worse once bindings to the KDE libs are complete, because
> there are much more of them.  To me, it seems like the best way to
> move forward is to reverse the decision made to keep the module name
> and namespace the same.  The modules would still be called QtGui4 and
> QtCore4, but would all populate a namespace named simply 'Qt'.  This
> seems like the cleanest solution.
Yes, that's probably the best thing to do. We do the same in Qyoto and QtRuby. 
There is currently one main 'Qt4' module with the namespace 'Qt' to load and 
QtWebKit (which is an extra module) is put in the same namespace. When we 
split up QtRuby and Qyoto into different modules (QtCore, QtGui...) we'll 
probably keep that layout.

-- 
Arno Rehn
arno at arnorehn.de



More information about the Kde-bindings mailing list