[Development] A modest proposal: disable lower-case keywords (emit, foreach, forever, signals, slots) by default

Lars Knoll lars.knoll at qt.io
Tue Apr 14 17:28:23 CEST 2020

On 14 Apr 2020, at 17:02, Matthew Woehlke <mwoehlke.floss at gmail.com<mailto:mwoehlke.floss at gmail.com>> wrote:

On 14/04/2020 05.28, Lars Knoll wrote:
I believe there is mostly a consensus here to find a way to get rid
of those macros. But many of our users do seem to like the ‘emit’
keyword as an annotation to a signal emission, and it is being used
extensively in existing code bases.

You know what would solve this? The ability to define a *reflection* operator (with proper name scoping) that could apply to statements and/or access protection specifiers.

 class MyObject

 public Qt::slots:
   ...slots here...

   Qt::emit this->bar();

   using namespace Qt;
   emit this->bar();

   none->emit(...); // *not* the Qt::emit operator

If we played this right, maybe we could even reimplement MOC using reflection? (Stuff like Q_PROPERTY however might be hard, depending on if these operators are allowed to take a *space* delimited list of arguments rather than comma delimited.)

Maybe, but we can’t solve it with current C++ standards. I think we should simply go and change the default for the QT_NO_KEYWORDS macro in Qt 6. Then, it’s Q_SIGNALS, Q_SLOTS and Q_EMIT by default, and you’ll need to use a
#define to get them back: https://codereview.qt-project.org/c/qt/qtbase/+/297053


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20200414/8a287b6a/attachment.html>

More information about the Development mailing list