Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Apr 2009 10:20:08 +0300
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        deeptech71@gmail.com
Cc:        freebsd-chat@freebsd.org
Subject:   Re: My whitespace style
Message-ID:  <87bpqytmc7.fsf@kobe.laptop>
In-Reply-To: <49E5670C.8070708@gmail.com> (deeptech's message of "Wed, 15 Apr 2009 06:48:12 %2B0200")
References:  <49E2FBE2.8020305@gmail.com> <20090413140912.GC29833@Grumpy.DynDNS.org> <49E51B42.2060405@gmail.com> <320BA0A7-C5E0-40E5-97F9-F19BF1C61B29@hiwaay.net> <49E5670C.8070708@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 15 Apr 2009 06:48:12 +0200, deeptech71@gmail.com wrote:
> Could you please give me a (preferrably widely used) example of
> columnizing calls which cross different levels of indentation?

It's not so uncommon as it may initially seem...

I've seen switch() cases in several programs indented like this:

        switch (value) {
        case SOME_CONSTANT_NAME:            do_stuff_here();        break;
        case ANOTHER_CONSTANT_NAME:         do_some_other_stuff();  break;
        default:                            default_stuff();        break;
        }

I find this style horrible to read, but it does come with its own
variation of TAB- and space-related issues and it is apparently
attractive to a lot of people.

Composite structure initializations also use a style similar to this,
and will almost invariably end up looking horrendously misformatted when
TAB sizes are 'elastic', i.e.:

    struct foo {
        long magic;
        const char *name;
        struct {
            int curr;
            int next;
        } nested;
    };

    const struct foo statetab[] = {
        { 1,     "one",     {    1,     2}, },
        { 1,     "one",     {    2,     2}, },
        { 1,     "one",     {    3,     1}, },
        { 1,     "one",     {65535,     1}, },

        { 2,     "two",     {    1,     1}, },
        { 2,     "two",     {    2,     2}, },
        { 2,     "two",     {    3, 65535}, },
        { 2,     "two",     {65535,     1}, },

        ...

        { 65535, "invalid", {    1,     1}, },
        { 65535, "invalid", {    2,     1}, },
        { 65535, "invalid", {    3,     1}, },
        { 65535, "invalid", {65535,     1}, },
    };

This sort of alignment tends to generate *lots* of diff output when the
alignment of a column changes, but it is often used for state transition
tables of automata, and similar constructs.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87bpqytmc7.fsf>