<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 18 February 2014 06:00, Walter Bright <span dir="ltr"><<a href="mailto:newshound2@digitalmars.com" target="_blank">newshound2@digitalmars.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<br></div>
I tend to format such like this:<div><br>
<br>
         int difficulty;<br>
         switch(e.note.note)<br>
         {<br>
           case 60: .. case 71:  difficulty = 0;  break;<br>
           case 72: .. case 83:  difficulty = 1;  break;<br>
           case 84: .. case 95:  difficulty = 2;  break;<br>
           case 96: .. case 107: difficulty = 3;  break;<br>
           default:              difficulty = -1; break;<br>
         }<br>
<br></div>
By lining things up, it takes on a tabular appearance. People are good at inferring patterns, and such tabular arrangements make it easy to spot squeaky wheels.</blockquote><div><br></div><div>Me too, but you don't feel this is basically a hack?</div>

<div>About half of that text is repeated cruft, and there's no precedent for formatting well-structured code like that anywhere else in the language.</div><div>How long would you say you spend on average fiddling with the tabulation?</div>

<div>I am known to spend minutes pressing the space bar, trying to make it line up and look nice. And then invariably, some other case comes along, with a slightly longer identifier name, and you have to work your way up shifting everything around against with a bunch more spaces.. pollutes source control history, etc.</div>

<div>And then that case with the REALLY long identifier name comes along, and you end out with so many spaces surrounding all the other cases, that it becomes difficult to associate which line matches which case, so then you think to yourself, "this one long case is ruining my code, maybe I should break the pattern and fall this long one onto it's own line below...", and then you're just wasting time, pushing the spacebar key, trying to work around something that shouldn't have been an issue in the first place.</div>
<div>Often enough the break statements end up far off the right hand side of the screen due to that one long statement in the sequence; do you line them all up religiously far to the right? Or do you make an exception for that one long line, allowing it to span beyond the 'break' line, and keep the rest lined up nearer to the code they terminate?</div>

<div>Tell me this doesn't happen to you? Surely I'm not the only one that faces this sort of conundrum frequently when I try and use switch? :)</div><div><br></div><div>I can't see that practise as anything other than a formatting hack to deal with something that was structurally unsound in the first place.</div>

<div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
> Finally, you didn't address the suggestion to allow assignment of the switch > condition to a properly scoped variable: switch([x =] expression) ?<br>
<br></div>
That's probably a good idea.<br></blockquote><div><br></div><div>Cool, I'll bugzilla it. At least something useful may comes from my ranting :P</div></div></div></div>