MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:Michael Widenius Date:April 19 2009 3:21am
Subject:Re: coding style change proposal: switch exception
View as plain text  

>>>>> "Mats" == Mats Kindahl <mats@stripped> writes:

>> The reason to put the { on the switch line, was to avoid the 'ugly' case
>> where { and following case are on the same offset like in:
>> switch()
>> {
>> case
>> I prefer the current exception as you get a nice lineup of switch and
>> case, which I think is easier to read.

Mats> Hi Monty!

Mats> When I type the { on a separate line (as above), the case label and the start of
Mats> the switch lines up (as in the example above).

Yes, they line up by default. I however don't like this as it looks
strange to not have an extra indentation after a line with only one

This is the reason we initially decided to have the { on it's own
line; To keep the code easier to read and make the different
indentation that seams to be standard for the switch/case statement to
be less notable.

Mats> I am using Emacs 22 and the mysql style that is in our style guide under

Mats> Is that what you saw as the main problem, or did I misunderstood you?

Here is some different ways you can indent the switch/case statement:

  switch (a) {
  case 1:
  case 2:

  switch (a)
  case 1:
  case 2:

  switch (a)
    case 1:
    case 2:


Of these I like a) the best (as it makes it easy to see to which swich
a case aligns to).

Ingo seams to prefer c) (as far as I understand), but I think this is
harder to read and would also cause a massive patch if we would fix
all the source code (which we should, if the proposal would be

coding style change proposal: switch exceptionIngo Strüwing13 Mar
  • [style] change proposal: switch exceptionKonstantin Osipov17 Mar
    • Re: [style] change proposal: switch exceptionChad MILLER17 Mar
    • re: [style] change proposal: switch exceptionMichael Widenius6 Apr
  • re: coding style change proposal: switch exceptionMichael Widenius6 Apr
    • Re: coding style change proposal: switch exceptionMats Kindahl6 Apr
      • Re: coding style change proposal: switch exceptionMichael Widenius19 Apr
        • Re: coding style change proposal: switch exceptionIngo Strüwing20 Apr