kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #41539
Re: wxWidgets Event Tables or Bind and lambdas
I prefer the way Simon has it formatted, since the lambda follows the
general function formatting guidelines. I am indifferent to the grouping of
arguments around it though, and the clang-format script would seem to
prefer doing it this way:
function( arg1, arg2, arg3, arg4, arg5,
arg6, arg7 );
instead of each on its own line.
>From what I can tell, the clang-format lambda support is not very advanced,
so whatever is decided won't be enforceable through there. Note that the
formatting of the function I originally sent was with clang-format, and it
isn't really consistent with the lamdas (see the three times here:
https://git.launchpad.net/~imcinerney/kicad/tree/cvpcb/cvpcb_mainframe.cpp?id=2dbe12e1fb3a4c43751113889737dff03393d305#n195,
all of these are what clang-format had decided was best).
-Ian
On Fri, Jul 12, 2019 at 2:46 PM Simon Richter <Simon.Richter@xxxxxxxxxx>
wrote:
> Hi,
>
> My layout would be
>
> m_footprintListBox->Bind( wxEVT_RIGHT_DOWN,
> [this]( wxMouseEvent& )
> {
> this->PopupMenu( this->m_footprintContextMenu );
> } );
>
> Rationale:
>
> - it follows the "indent twice for round parentheses" rule
> - the lambda begins on the first character in the line
> - it keeps the lambda on the same indentation level
> - it leaves enough space for the lambda without too many extra breaks
> - the closing parenthesis follows the last argument on the same line
>
> The "wxEVT_RIGHT_DOWN" would technically be on the same level as the
> lambda, so
>
> m_footprintListBox->Bind(
> wxEVT_RIGHT_DOWN,
> [this]( wxMouseEvent& )
> {
> this->PopupMenu( this->m_footprintContextMenu );
> } );
>
> would be equivalent. We have both
>
> function( arg1, arg2, arg3, arg4, arg5,
> arg6, arg7 );
>
> and
>
> function(
> arg1,
> arg2,
> arg3,
> arg4,
> arg5,
> arg6,
> arg7 );
>
> in the codebase, as well as several instances where some arguments are
> grouped tighter than others, e.g.
>
> function( something.x, something.y,
> something.w, something.h );
>
> instead of
>
> function( something.x, something.y, something.w,
> something.h );
>
> I think the usual rule applies: the compiler doesn't care, so the highest
> priority is that it should be human readable.
>
> Simon
>
Follow ups
References