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

Lars Knoll lars.knoll at qt.io
Mon Feb 24 12:35:46 CET 2020


On 24 Feb 2020, at 12:30, André Somers <andre at familiesomers.nl<mailto:andre at familiesomers.nl>> wrote:

Hi Lars,

Sent from my phone, please excuse my brevity

On 24 Feb 2020, at 12:27, Lars Knoll <lars.knoll at qt.io<mailto:lars.knoll at qt.io>> wrote:



On 21 Feb 2020, at 17:39, Thiago Macieira <thiago.macieira at intel.com<mailto:thiago.macieira at intel.com>> wrote:

On Friday, 21 February 2020 04:59:02 PST Ville Voutilainen wrote:
Having a keyword-extension to normal C++ is ugly as sin, to some of
us. It causes
fair amounts of "wtf is that?".

That was my reaction when I first saw it, in 1999.

Over 20 years later, I don't bat an eye.

After 20 years, my eyes simply ignore any ‘emit’ in the source code.

In any case, I do understand why Qt added emit as a keyword 25 years ago. But today, we do have IDEs which should be able to figure out on the fly whether a function call is a signal emission (as they already do for virtual vs non virtual methods). So why don’t we move the over to be a tooling problem? Simply highlight signal emissions differently in the IDE and you don’t need a keyword for it anymore. It’s also safer, as the keyword can be forgotten or applied to the wrong places.

You seem to assume everyone used QtCreator as their IDE of choice. That is not a reasonable assumption I think.

No, but ‘emit’ as a macro that expands to nothing (and for that matter all other proposals such as [[qt::emit]] or qEmit()) is not a great solution neither. It can easily be forgotten or placed in the wrong position (and I’ve seen both quite a few times).

Cheers,
Lars

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20200224/ff232ee5/attachment-0001.html>


More information about the Development mailing list