DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L1879
Version: 2.0-current


The coding standard document states that the FLTK coding style is the GNU
style (which it isn't) and that the GNU style is essentially the K&R style
(which it certainly isn't).

>From the web page:
-----------------------------
The FLTK code follows the GNU coding style, which is also essentially the
K&R coding style. While many of the developers are not entirely satisfied
with this coding style, no one has volunteered to change all of the FLTK
source code (currently about 54,000 lines of code!) to a new style.

The GNU/K&R coding style can be summarized with the following example
code:

    int
    function(int arg) {
      if (arg != 10) {
        printf("arg = %d\n", arg);
        return (0);
      } else {
        return 1;
      }
    }
-----------------------------

This is NOT the GNU style, of course. The GNU coding style is more like
the "ANSI" style but with two levels of indentation. (See
http://www.gnu.org/prep/standards/html_node/Formatting.html.)

The FLTK code appears to be using what is essentially the so-called "K&R
style," as shown above.

The GNU style for the same snippet would look like this:

    int
    function (int arg)
    {
      if (arg != 10)
        {
          printf ("arg = %d\n", arg);
          return 0;
        }
      else
        {
          return 1;
        }
    }

Here's the recommended changed text for that section of the document. (It
removes inaccurate references to GNU.) (I've also taken the liberty of
correcting the inconsistency WRT parentheses on return expression.)
-----------------------------
The FLTK code follows essentially the K&R coding style. While many of the
developers are not entirely satisfied with this coding style, no one has
volunteered to change all of the FLTK source code (currently about 54,000
lines of code!) to a new style.

The coding style can be summarized with the following example code:

    int
    function(int arg) {
      if (arg != 10) {
        printf("arg = %d\n", arg);
        return 0;
      } else {
        return 1;
      }
    }
-----------------------------

BTW, what style would the developers prefer? (So-called "ANSI," i.e.,
four-space indents, opening brace on own line, aligned directly above
closing brace?) I may well volunteer to modify all 54,000+ lines of the
code to use the new style, provided that an existing code reformatter such
as astyle or bcpp adequately supports the chosen style. (In my experience,
astyle does a good job except that it incorrectly indents #if and such
(i.e., it does not indent them, thus breaking the visual cues for the
block structure); but I have a workaround for that).)

(In reality, I suspect it would prove more difficult for the active
developers to reach consensus on a new style than it would be to implement
it once a decision has been made.)


Link: http://www.fltk.org/str.php?L1879
Version: 2.0-current

_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to