← Back to team overview

kicad-developers team mailing list archive

Re: wxWidgets Event Tables or Bind and lambdas

 

On 7/12/2019 8:46 AM, Simon Richter wrote:
> Hi,
> 
> My layout would be
> 
> m_footprintListBox->Bind( wxEVT_RIGHT_DOWN,
>         [this]( wxMouseEvent& ) 
>         { 
>             this->PopupMenu( this->m_footprintContextMenu ); 
>         } );

I like the way this looks compared to the other formats proposed.  If
there are no objections, I can add it to the coding policy.

> 
> 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
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp
> 


References