<p>Any good editor (*cough*emacs*cough*) will properly indent and clue the human into the error. Its all about the text editor. ;)</p>
<p>--<br>
Sent from my phone... a G2 running CM7 nightlies!</p>
<div class="gmail_quote">On Feb 12, 2011 5:11 PM, "Tim Watts" <<a href="mailto:tim@cliftonfarm.org">tim@cliftonfarm.org</a>> wrote:<br type="attribution">> [ pardon me for I'm butting in ]<br>> <br>
> You're right: to the compiler it's just style. But I look at them as<br>> cheap insurance against future bugs. <br>> <br>> // The code in Feb 2011:<br>> if (somethingIsTrue())<br>>         doASimpleTask()<br>
> else<br>>         doTheAlternateTask()<br>> <br>> // The code in Feb 2012:<br>> if (somethingIsTrue())<br>>         doASimpleTask();<br>> else<br>>         doTheAlternateTask();<br>>         doTheWorkAroundToo();<br>> <br>
> Of course, this is broke and you may very well have caught it. But<br>> enclosing it in {} in the first place would have avoided the need to<br>> even think about it. About the only time I'll omit braces is with<br>
> conditionals that are one-liners (and sometimes not even then):<br>> <br>> if (log.isDebugEnabled()) log.debug("now i'm opening the pickle jar.");<br>> <br>> <br>> On Sat, 2011-02-12 at 16:06 -0500, Joshua wrote:<br>
>> James,<br>>> <br>>> I put the {} around the block, (which helps to guard against certain <br>>> bugs). the {} make the code easier to read, but I do not know that with <br>>> one line of code they prevent any bugs.<br>
>> <br>>> from what I read, and the discussions I had on iirc, a dangling else is <br>>> more of a grammatical (readability) thing, from a human perspective, the <br>>> compiler /interpreter will take care of any ambiguity with if/else <br>
>> blocks, as far as I can tell. The else attaches to the nearest if <br>>> block. I can see the issue from a psuedocode perspective, where the <br>>> grammatical ambiguity can cause problems when actually implementing the <br>
>> code, but one the code is written it is the placement of the } from <br>>> preceding if statements that determine which 'if' the 'else' will attach to.<br>>> <br>>> or am I missing something?<br>
>> <br>>> <br>>> <br>>> Maybe that is all the dangling else is: a semantics things.<br>>> <br>>> <br>>> James Sumners wrote:<br>>> > My only suggestion would be to fix your dangling else block --<br>
>> > <a href="http://pastebin.com/pTzUQzjJ">http://pastebin.com/pTzUQzjJ</a><br>>> ><br>>> > On Sat, Feb 12, 2011 at 2:53 PM, Joshua <<a href="mailto:jrtroberts@gmail.com">jrtroberts@gmail.com</a>> wrote:<br>
>> > <br>>> >> I am working with an API for currency conversion from<br>>> >> <a href="http://www.thomasknierim.com/index.php?s=currencyconverter&Submit=Search">http://www.thomasknierim.com/index.php?s=currencyconverter&Submit=Search</a><br>
>> >> <<a href="http://www.thomasknierim.com/index.php?s=currencyconverter&Submit=Search">http://www.thomasknierim.com/index.php?s=currencyconverter&Submit=Search</a>><br>>> >><br>>> >> It is all written is Java.<br>
>> >><br>>> >> The initCacheFile() method worked fine under windows, but it broke<br>>> >> under linux.<br>>> >><br>>> >> The original code grabbed the path to the java temp directory and then<br>
>> >> concatenated a file name onto the end of it. I do not know what it<br>>> >> produces under windows, but my suspicion is that windows is something<br>>> >> like </driveletter:\pathtotemp\/> with the trailing '\' included.<br>
>> >><br>>> >> Under linux the call to return the temp directory returns '/tmp' and<br>>> >> then the concatenating of '/filename/' creates a file named<br>>> >> /tmp/filename/ instead of /tmp//filename/ so the application was trying<br>
>> >> to write to / where it did not have permissions. So I had to write a<br>>> >> fix. Still not sure the fix is this best.<br>>> >><br>>> >><br>>> >> Maybe someone can look at the code I wrote and let me know.<br>
>> >><br>>> >> <a href="http://pastebin.com/vsC6vZRU">http://pastebin.com/vsC6vZRU</a><br>>> >><br>>> >> The old code is commented out.<br>>> >><br>>> >> Joshua Roberts<br>
>> >> <br>>> ><br>>> ><br>>> > <br>>> <br>>> _______________________________________________<br>>> Ale mailing list<br>>> <a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
>> <a href="http://mail.ale.org/mailman/listinfo/ale">http://mail.ale.org/mailman/listinfo/ale</a><br>>> See JOBS, ANNOUNCE and SCHOOLS lists at<br>>> <a href="http://mail.ale.org/mailman/listinfo">http://mail.ale.org/mailman/listinfo</a><br>
> <br>> <br>> _______________________________________________<br>> Ale mailing list<br>> <a href="mailto:Ale@ale.org">Ale@ale.org</a><br>> <a href="http://mail.ale.org/mailman/listinfo/ale">http://mail.ale.org/mailman/listinfo/ale</a><br>
> See JOBS, ANNOUNCE and SCHOOLS lists at<br>> <a href="http://mail.ale.org/mailman/listinfo">http://mail.ale.org/mailman/listinfo</a><br></div>