[PyKDE] namespaces in sip
Patrick Stinson
ajole-1 at gci.net
Thu Oct 16 20:53:01 BST 2003
Right. _Great_ help on the qt qualification bit, and a good analogy. Thanks!
The 'PK_' is my prefix for every class in the library. I removed it yesterday
after putting all of the classes in the 'PK' namespace, hence my original
post. As a segway: I'm still not convinced that python isn't just C on OO
drugs; I love it.
wrt qualification: yes, after changing something minor yesterday that fell
into place. The correct full qualification on reference is the tweaky part
with sip. One must only learn the correct syntax...
On Thursday 16 October 2003 07:58, Jim Bublitz wrote:
> On Wednesday October 15 2003 16:26, Patrick Stinson wrote:
> > ...and now if we have something like
> >
> > namespace PK
> > {
> > class Port
> > {
> > enum Type
> > {
> > Input,
> > Output
> > };
> > PK_Port(PK_Port::Type);
> > };
> >
> > };
> >
> > we should get an error because of the nested [enum], correct?
> > hope not...
>
> PK::Port::Type - otherwise it should work.
>
> PK_Port is only a (unqualified) method name. If you meant PK_Port
> to be the ctor for class Port, it should be:
>
> namespace PK
> {
> class Port
> {
> enum Type
> {
> Input,
> Output
> };
>
> Port(PK::Port::Type);
> };
> };
>
> The class name (in the 'class' statement), the ctor *name* and
> dtor *name* don't get qualified - everything else does
> ("everything else" is a *reference* to the name, not a
> definition of the name). Same with the enum name - no
> qualification when it's declared, but qualified wherever it's
> referenced.
>
> Here's an analogy that might help. Imagine a filesystem tree
> like:
>
> PK
>
> |_Port
> |
> |_Type
>
> None of those is qualified. But if I want a file somewhere in
> 'Type', I need to do /PK/Port/Type/file - sip doesn't have a
> concept for namespaces like a file system's './' or '../' or
> 'current directory' and always needs the full 'path' to an
> object to find it (but not to define it).
>
> The underscore ("_") naming is a sip convention for generated
> code (if that's where it came from), but syntactically it
> doesn't mean anything except "here's a name that I gave a prefix
> to". You're actually writing C++ syntax - you just don't get to
> leave things out for sip like you do for C++.
>
> Jim
>
> _______________________________________________
> PyKDE mailing list PyKDE at mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
More information about the PyQt
mailing list