Re: OT: Why is C so popular?

From: Steve Lamb (grey_at_dmiyu.org)
Date: 08/28/03

  • Next message: Steve Lamb: "Re: OT: Why is C so popular?"
    Date: Wed, 27 Aug 2003 23:55:23 -0700
    To: debian-user@lists.debian.org
    
    
    

    On Wed, 27 Aug 2003 23:52:35 -0600
    Jacob Anawalt <jacob@cachevalley.com> wrote:
    > Was this code on a Unix system, or did you have one nearby? Did you know
    > about the indent program at the time? (man indent)
     
    > It _seems_ to work for me to convert someone elses sytle (or lack of it)
    > in coding C into a format that I like (K&R).

        That's just it, I don't like C indenting any more, period. It isn't
    "someone else's style" that is the problem, it is the fact that it is the
    antithesis of how I've grown to like to code. Lemme put it this way:

    C:
    if foo
        bar;

    Python:
    if foo:
        bar

    Want to extend it?

    Python:
    if foo:
        bar
        baz

    C:
    if foo
        bar;
        baz;

    Bzttttt, wrong....

    if foo {
        bar;
        baz;
    }

        But wait, baz really shouldn't be a part of the if statement!

    Python:
    if foo:
        bar
    baz

    C:
    if foo
       bar;
    baz;

        No, darn it, only if foo is false, really.

    Python:
    if foo:
        bar
    else:
        baz

    C:
    if foo
        bar;
    else
        baz

    Nope...

    if foo {
        bar;
    }
    else {
        baz;
    }

        It boils down to this. In Python if I want something to be in a block, I
    smack tab and don't even need to worry about my editor doing the right thing.
    I tell it to set tab stops to 4, save all spaces and how the code is written
    is how it will run. If I need to pull that call out of a block I just delete
    space to line up to the previous block. << or >> or V<, V> or several other
    commands in vim work nicely for this. If I need to add to a block I just tab
    over to the right spot and there it is.

        The main problem with "other people's style" isn't so much a matter of
    indenting blocks (any half-assed decent programmer does that to some degree)
    it is a matter of block delimiter placement. Some people prefer to have the
    block delimiters separate of the line that starts the block. Some prefer the
    opening on the same line so the closing lines up with the keyword opening the
    block. Some consider else its own block and having it line up with the if
    makes sense. Others consider it a continuation so they slap it onto the end
    of the if block. What have I described?

    a:
    if cond
    {
        block
    }
    else
    {
        block
    }

    b:
    if cond {
        block
    }
    else {
        block
    }

    c:
    if cond {
        block
    } else {
        block
    }

        3 different styles. But remove the damnedable braces and what are you
    left with?

    if cond
        block
    else
        block

        Hence it is not other people's style I dislike, it is the freakin' braces.

    -- 
             Steve C. Lamb         | I'm your priest, I'm your shrink, I'm your
           PGP Key: 8B6E99C5       | main connection to the switchboard of souls.
    -------------------------------+---------------------------------------------
    
    

    -- 
    To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
    


  • Next message: Steve Lamb: "Re: OT: Why is C so popular?"

    Relevant Pages

    • Re: how to deserialize variable element/node
      ... string bar; ... baz[] Baz; ... Your two XML fragments would have to be represented in an XML schema by ...
      (microsoft.public.dotnet.xml)
    • Re: Regular Expressions...
      ... (foo, bar, baz) ... an object which allows access to the grouped matches as a sequence. ...
      (comp.lang.python)
    • Re: macros
      ... (:method ((foo foo) ... (baz baz)) ... in Anonymous C Lisper's post (bar bar)" ... latter so you know that this is actually the generic function you want). ...
      (comp.lang.lisp)
    • Re: OT: Why is C so popular?
      ... >>about the indent program at the time? ... > if foo ...
      (Debian-User)
    • Re: creating several rows with one insert?
      ... Is there some clever way to cause this to happen in SQL, ... SQL> create table t1as select 'foo' from dual ... union all select 'bar' from dual union all select 'baz' from dual; ...
      (comp.databases.oracle.misc)

    Loading