[Bf-committers] code style proposal: switch statements
sergey.vfx at gmail.com
Sun Jul 14 14:22:46 CEST 2013
Me also agreed. I've missed such a thing in our guidelines couple of times
On Sun, Jul 14, 2013 at 5:39 PM, Brecht Van Lommel <
brechtvanlommel at pandora.be> wrote:
> Agreed, the proposed code style is fine with me.
> On Sun, Jul 14, 2013 at 5:44 AM, Campbell Barton <ideasman42 at gmail.com>
> > Yesterday I went over missing break's in switch statements and found a
> > surprising number of real bugs/errors in code (over 10), some rather
> > bad errors like boids 'random' behavior option, falling through to
> > 'average'.
> > We didn't yet decide on details for switch() statements in our current
> > style-code , but I think doing so would help avoid more mistakes
> > like this as well as making code easier to follow.
> > Most simple errors are not hard to spot errors but some code grows
> > over time - we had a mistake with a switch nested inside a switch for
> > eg.
> > Note that this proposal is mostly what we do now anyway, so no large
> > code cleanup commits needed for this and proposal is minimal.
> > Proposal:
> > - be consistent with placement of break, indent and include within
> > - intentional fall-through after statements in a case _must_ be
> > (however successive case statements with no code can go without
> > Heres an image: and text: of what I think is reasonable and an
> > example of whats not below.
> > For an example of mixed up 'break' placement in current code, see
> > BKE_object_minmax in object.c
> > : http://wiki.blender.org/index.php/Dev:Doc/CodeStyle
> > : http://www.graphicall.org/ftp/ideasman42/bad_switch_example.png
> > : http://www.graphicall.org/ftp/ideasman42/bad_switch_example.c
> > --
> > - Campbell
> > _______________________________________________
> > Bf-committers mailing list
> > Bf-committers at blender.org
> > http://lists.blender.org/mailman/listinfo/bf-committers
> Bf-committers mailing list
> Bf-committers at blender.org
With best regards, Sergey Sharybin
More information about the Bf-committers