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

Mitch Curtis mitch.curtis at qt.io
Mon Feb 24 13:22:14 CET 2020


> -----Original Message-----
> From: Development <development-bounces at qt-project.org> On Behalf Of
> Lars Knoll
> Sent: Monday, 24 February 2020 12:25 PM
> To: Thiago Macieira <thiago.macieira at intel.com>
> Cc: Qt development mailing list <development at qt-project.org>
> Subject: Re: [Development] A modest proposal: disable lower-case
> keywords (emit, foreach, forever, signals, slots) by default
> 
> > On 21 Feb 2020, at 17:39, Thiago Macieira <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.

That's one way of handling it, but I don't see the harm in keeping it for those who want to use it. I don't think anyone has explained what that harm is yet.

>It’s also safer, as the keyword can be forgotten or applied to the wrong places.

I don't think I've ever seen this happen, and am curious as to why it's dangerous. It might be misleading, but it couldn't cause harm, just a moment of mild confusion. In terms of harm, I see it as on par with (or probably even less dangerous than) an out-dated code comment. I think that marking signal emissions aids the reader (and there is certainly *a lot* of Qt code that could e.g. use more code comments to aid people who have to maintain it).

> Cheers,
> Lars
> 
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> https://lists.qt-project.org/listinfo/development


More information about the Development mailing list