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

Matthew Woehlke mwoehlke.floss at gmail.com
Tue Feb 25 20:17:19 CET 2020


On 21/02/2020 09.02, Ville Voutilainen wrote:
> Getting back to macro vs. function.. I think using a function wrapper
> is fine, considering that signals can't
> meaningfully return, so the prvalue/xvalue issue doesn't arise.

AFAIK, signals *can't* return, period. The signal body is written by
moc, not the developer, and I'm not aware of any way to generate a
signal method body that involves returning something.

> Yeah, I'm sure we'll have no trouble finding people who think
> 
> qEmit(mah_bucket_callback());
> 
> is unacceptably ugly compared to
> 
> qEmit mah_bucket_callback();

Personally, I would vote for:

  template <typename Signal, typename... Args>
  QObject::emit(Signal, Args&&...)

...which not only avoids an extra set of parentheses, but could actually
*verify* that what you're trying to emit is really a signal. (It has to
be a member function, because it needs `this`.)

-- 
Matthew


More information about the Development mailing list