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

Matthew Woehlke mwoehlke.floss at gmail.com
Fri Feb 28 21:06:06 CET 2020


On 28/02/2020 13.32, Thiago Macieira wrote:
> On Friday, 28 February 2020 07:28:34 PST Matthew Woehlke wrote:
>> If we had to do it over again, it might make sense to follow Python and
>> make signals *objects* instead of *methods*. Then the code would look like:
>>
>>   this->emptied.emit(...);
> 
> Binary compatibility issue: if it's a member of the class, it can't be added 
> or removed without changing the class's size and layout, so it would tie our 
> hands for future improvements.

Good point. Although...

> You'd see instead:
> 
>     this->emptied().emit(...);
>     connect(foo, foo->emptied(), ...);

...this might actually be better, since it would mean we still have MOC
generating the code for the signal. (I was trying to figure out how MOC
would generate the object initialization logic, and failing. I suspect
this would work better. I wonder if we could even introduce this new
style without breaking existing code source compatibility?)

...but I think connections would still look like either:

  connect(foo, &Foo::emptied, ...);

...or:

  connect(foo->emptied(), ...);

-- 
Matthew


More information about the Development mailing list