On 2007-08-09 23:48:03 -0700, Steve Lamb wrote:
> Vincent Lefevre wrote:
> > Braces are not a problem: they are kept in a copy-paste, and if for
> > some reason a brace is missing (because you did a mistake), then you'll
> > get a syntax error 
> 
>     Unless, of course, you are programming in C with that pesky...
> if
>   foo;
>   bar;
> 
>     ...problem.

Of course, you need to be careful on what you copy-paste. Problems
can also happen with:

  foo1;
  foo2;
  foo3;

if you want to move these three lines, but if you forget the 3rd one.

Now, concerning the C language, there's a reason why it is recommended
to always use braces even when they aren't needed...

> > In Python, you may need to re-indent (correctly!) all what you've
> > copy-pasted, and if you forget an indentation, the syntax will still
> > be valid.
> 
>     Which is not that hard.  Have you done it?  Doubt it.  I have, many times.
>    Say I'm 3 levels deep and paste something 2 levels deep.  Like this:
> 
>             for foo in bar:
>         if foo > 200:
>             print baz
>         else:
>             print spam

OK, not in every case. But there are cases where it is still valid.
For instance, if you have:

        for foo in bar:
            print blah1
            print blah2

and you want to paste:

        if foo > 200:
            print baz
        else:
            print spam

so that you get:

        for foo in bar:
            print blah1
        if foo > 200:
            print baz
        else:
            print spam
            print blah2

which is valid, isn't it? You need to re-indent to:

        for foo in bar:
            print blah1
            if foo > 200:
                print baz
            else:
                print spam
            print blah2

and it's too easy to get this wrong. And if you want to check
a posteriori that you (or someone else) did it right, standard
tools like "diff -w" (useful if other languages) won't give you
any valuable information.

>     Secondly, as I stated earlier, any programmer's editor will be able to
> indent by blocks.

This is useful. However when the blocks are large (e.g. if they don't
fit in the screen), it's easy to make a mistake.

>  I know vim and idle can, pretty sure emacs can as well for those of
> that sect.

The problem with Emacs is that the mark changes too easily. So, this
is not reliable (I always check my changes with "diff" / "diff -w").

>     Also, as I said, would you really trust someone who doesn't
> reindent their code so they can read it even if they are cut and
> pasting code with braces?

No, but again, changes made by someone can easily be checked with
"diff -w". Personally, I have all my codes automatically re-indented.

-- 
Vincent Lefèvre <[EMAIL PROTECTED]> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to