← Back to team overview

kicad-developers team mailing list archive

Re: "auto" policy

 

This all sounds good to me.  I'm the author of that offending line and am
happy to update my code accordingly.

-Jon

On Fri, Apr 5, 2019 at 8:58 AM Wayne Stambaugh <stambaughw@xxxxxxxxx> wrote:

>
> On 4/5/19 6:39 AM, Jeff Young wrote:
> > Do we have a policy on when to use auto?
>
> No but we should create one since I'm seeing it being used fairly often.
>
> >
> > Personally, I like it when it removes repetition.  For instance:
> >
> >     auto pin = new SCH_PIN();
>
> I'm fine with this since the type is obvious.
>
> >
> >
> > And I like it when it removes stupid template things like std::pair<>:
> >
> >     for( auto it : my_unordered_map )
>
> I'm fine with this as well since an iterator is implied and life is too
> short to be typing out iterator types.
>
> >
> >
> > But I don’t like it in other cases.  This reduces readability for me:
> >
> >     auto pos = pin->GetPosition();
>
> I don't like this either.  I have no idea what type GetPosition()
> returns and I really don't want to have to look it up.
>
> >
> >
> > However, I’m just one voice, and the idea of when something is a “stupid
> > template thing” and when it isn’t is admittedly pretty ill-defined.
> >
> > How do others feel?
> >
> > Cheers,
> > Jeff.
> >
> >
> > _______________________________________________
> > 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
> >
>
> _______________________________________________
> 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