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

Jaroslaw Kobus Jaroslaw.Kobus at qt.io
Mon Mar 2 08:45:29 CET 2020


Allan Sandfeld Jensen (27 February 2020 23:03) replied:
> That is how I see it too. It essentially violates Qt code guidelines. If it
> was a normal method we would name it "emitEmptied()", so far we have just
> lived with "emit emptied()" instead.

The issue is that if you want to emit a signal, "emitEmptied()" sounds OK, while when you want to connect to it, you don't want to connect to "emitEmptied", but to "emptied".

Just my 4 cents (this amount wasn't offered in this thread, yet).

Jarek
________________________________________
From: Development <development-bounces at qt-project.org> on behalf of Edward Welbourne <edward.welbourne at qt.io>
Sent: Friday, February 28, 2020 10:34 AM
To: Allan Sandfeld Jensen
Cc: development at qt-project.org
Subject: Re: [Development] A modest proposal: disable lower-case        keywords        (emit, foreach, forever, signals, slots) by default


On 26/02/2020 07.42, Tor Arne Vestbø wrote:
>>> As others have argued, a signal is not special, in the sense that any
>>> function can do anything, including emitting signals, so annotating it
>>> doesn’t seem critical, as we apparently are fine without in all other
>>> cases.

On Thursday, 27 February 2020 21:51:18 CET Matthew Woehlke wrote:
>> Taking a step back... I think some of the reason for the current
>> situation has to do with API design. Which of these is easier to understand?
>>
>>   if (map.empty())
>>     emptied();
>>
>> - vs. -
>>
>>   if (map.isEmpty())
>>     emit emptied();
>>
>> One reads like plain English. The other is missing words in a way that
>> can confuse readers.

Allan Sandfeld Jensen (27 February 2020 23:03) replied:
> That is how I see it too. It essentially violates Qt code guidelines. If it
> was a normal method we would name it "emitEmptied()", so far we have just
> lived with "emit emptied()" instead.

Indeed; most of the case for "emit" can be answered by a sensible naming
convention.  Even the case of "functions that trigger signals" can be
handled by that, when it really matters.

The only problem is that (as a legacy of having had a "keyword" for so
long) we have a bunch of signals whose names don't conform to that
convention.  No-one has suggested we abolish "emit" overnight; so there
shall be time to change the names of things during the course of the
transition to retiring it.

        Eddy.
_______________________________________________
Development mailing list
Development at qt-project.org
https://lists.qt-project.org/listinfo/development


More information about the Development mailing list