Introducing Cobra
Gabriel Sechan
gsechan at hotmail.com
Wed Jan 2 16:02:02 PST 2008
----------------------------------------
> Date: Wed, 2 Jan 2008 15:20:37 -0800
> From: kplug at davidb.org
> To: kplug-lpsg at kernel-panic.org
> Subject: Re: Introducing Cobra
>
> On Wed, Jan 02, 2008 at 05:12:32PM -0600, Gabriel Sechan wrote:
>
>>While you can put a brace in the wrong spot as a bug, you can do the same
>>with whitespace. You'll never get that type of error from just moving
>>code around. THis is absolutely a reason why indent based blocking is a
>>bad thing.
>
> I guess I don't understand. When moving blocks of code around, I _often_
> have to fix up braces and such to make the structure of the code correct.
> Generally, I have to fix both the braces and the indentation to get what I
> want, and it is usually the indentation that tells me when things are
> wrong.
SInce I almost always move a block (or multipel blocks) at a time, I have to change the indentation on the line with the brace, but not add/delete braces themselves. I just copy them with the rest of the code. I rarely start at one level of nesting and end at another, which would require fixing braces.
>
> The times I've been bitten where were the indentation was correct, but the
> braces didn't get copied with the right part of the block. It was only the
> syntax error hundreds of lines later that pointed out the problem.
>
> With indentation as the nesting itself, I only have to fix one of these,
> and that's the one that is blatantly obvious.
Except that is isn't:
if foo()
bar()
baz()
How far should baz be indented? It can be difficult to remember, especially if you were distracted and came back to it. WIth braces, you always know.
Note: this ignores the fact some languages allow you to not brace off 1 liners. I agree that was a mistake, and its a side issue to the discussion here.
>
> Please don't tell me you would even consider using the code with the
> indentation wrong.
>
I would for a quickie bench test, but I'd fix it before submitting.
>>Indent based blocking is an attempt at solving a social problem (people
>>who don't indent, although I've never actually met one of these people)
>>with a technical solution (indentation as semanticly meaningful). That
>>just doesn't work- you're causing at least as many problems as you're
>>stopping (probably far more, because I've never met a programmer who
>>didn't indent predictably) and adding in whole new classes of bugs. The
>>correct answer is to educate the people who don't indent.
>
> Where did you get the idea that indentation based blocking is trying to
> solve this problem? It was created for people who were indenting so that
> they only had to specify the nesting in one way. It certainly isn't
> primarily motivated as a way to force people to indent.
>
Because I can't think of any other problem it could possibly be attempting to solve. I only see problems it causes. Also, I've heard this line of logic used before by python users.
>>You're right, I meant to type auto-shift. Same issue though- if your
>>language requires an editor to have a specific tool to avoid a common bug,
>>your language is fatally flawed. Python isn't even a remote consideration
>>for me due to this. I've actually rewritten small (
>
> The language doesn't require anything more out of my editor than another
> laugnage does. I need my editor to be able to match braces to be able to
> do sane rearrangement of code in C, and I need it to be able to change
> indentation for Python. Actually, I would argue that the indentation
> change is much easier to do manually than trying to match braces visually.
>
Not at all- since 99% of the time you move braces in pairs, you just don't have to worry about it. It will just work.
> Again, this seems to be more of an argument in favor of Python, rather than
> against.
>
If you think that, we're coming at this from such disparate opinions we can't understand each other, because I'm utterly and completely at a loss for any way of thinking that.
Gabe
_________________________________________________________________
The best games are on Xbox 360. Click here for a special offer on an Xbox 360 Console.
http://www.xbox.com/en-US/hardware/wheretobuy/
More information about the KPLUG-LPSG
mailing list