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

Matthew Woehlke mwoehlke.floss at gmail.com
Tue Apr 14 17:02:41 CEST 2020


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
   {
     Qt::Q_OBJECT;

   public Qt::slots:
     ...slots here...
   };

   MyObject::foo()
   {
     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.)

-- 
Matthew


More information about the Development mailing list