[Development] Some Qt3D feedback

Smith Martin Martin.Smith at theqtcompany.com
Thu Jun 18 12:51:01 CEST 2015


Do you also advocate rules for using namespaces in Qt? What rules does KDE use?

>From following this thread, the rules that seem natural to me would be:

1. For a new module, either put everything in a namespace or don't use a namespace at all.
2. If you put everything in a namespace:
2.1 The name of the namespace should begin with Qt, e.g. Qt3D.
2.2 The classes in the namespace should not be prefixed with Q.
3. In the documentation for the namespace, recommend that, for readability, users should not use using.

martin

________________________________________
From: development-bounces+martin.smith=theqtcompany.com at qt-project.org <development-bounces+martin.smith=theqtcompany.com at qt-project.org> on behalf of Marc Mutz <marc.mutz at kdab.com>
Sent: Thursday, June 18, 2015 1:32 PM
To: development at qt-project.org
Subject: Re: [Development] Some Qt3D feedback

On Thursday 18 June 2015 11:37:48 Knoll Lars wrote:
> >Curiously, you didn't list any pro-namespace arguments. I don't know what
> >to  make of this, but I fear that a decision is being made based solely
> >on arguments from one side.
>
> So what are the arguments from your point of view then? Apart from
> namespaces being in fashion.

If this was about fashion, then namespaces have been fashionable since at
least the early 2000s (std::, boost::).

Pro namespaces:

- It's the standard way of partioning the name space. C++ users understand it,
  the C++ language understands it, and the C++ compiler does, too.

- namespaces act as an ADL barrier (did you ever got lost in the error
  compilers spew out when you get a simple == wrong? they rival template error
  messages, and the reson is that they're all put into the global scope).

- related: they provide a module-wide C++ scope (std::rel_ops example)

- you cannot (meaningfully) use inline namespaces for versioning (an option we
  should at least consider) if you don't have a namespace in which to put
  them.

- the user has the option of whether she wants to be explicit or convenient.
  Qt trying to impose this decision on its users by name prefixing is
  a) ignoring the fact that many users I know (QtC, KDE(pim)[1], to name the
     biggest and most well-known), liberally use using-directives and do just
     fine. The standard books teach this, too.
  b) preposterous. Imagine your OS took away your hierarchical filesystem and
     required you to type
         $EDITOR homelarsdevQt5qtbasesrccorelibkernelqobject.h
     every time. How long until you'd go mad? But hey, you cannnot _not_ see
     the path of each file, even when someone pastes it on the internet.
  But this is what you're imposing on your users. It's ok as long as it was
  just Q. That's cute. But QDesignerCustomWidgetCollectionInterface or
  QDeclarativeNetworkAccessManagerFactory is *NOT* cute. It's ridiculous.

[1] And no-one, not even QtC, uses so many libraries as KMail does. If you are
    looking for namespace experience, look there.

Thanks,
Marc

--
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt Experts
_______________________________________________
Development mailing list
Development at qt-project.org
http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list