Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2002:
[Freeciv-Dev] Re: possible addition to README.coding_style
Home

[Freeciv-Dev] Re: possible addition to README.coding_style

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Raimar Falke <rfalke@xxxxxxxxxxxxxxxxxxx>
Cc: Freeciv-Dev <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: possible addition to README.coding_style
From: Mike Kaufman <mkaufman@xxxxxxxxxxxxxx>
Date: Sun, 3 Feb 2002 16:22:55 -0600

you already know what I think, but...

> > > I still prefer -l75. What about /* *INDENT-OFF*  */ and /* *INDENT-ON* */?
> > 
> > that's fairly silly, and completely destroys the purpose for which I
> > want to do this: I'll give a few examples which truly grate me:
> > 
> >   gtk_box_pack_start(GTK_BOX
> >                      (GTK_DIALOG(report_dialog->shell)->action_area),
> >                      report_dialog->btn_delete, TRUE, TRUE, 0);
> > 
> > vs.
> > 
> >   gtk_box_pack_start(GTK_BOX(GTK_DIALOG(report_dialog->shell)->action_area),
> >                      report_dialog->btn_delete, TRUE, TRUE, 0);
> 
> The first is one line larger. Anything else?
> 

no, that's it in a nutshell. The 1st make code longer and therefore you
can't fit as much in a screenful and therefore you don't get the same
sense of code continuity, and you're wasting the right-hand part of
your terminal...and it's just uglier :)

> > I suppose you would want?
> > 
> >   /* *INDENT-OFF*  */
> >   gtk_box_pack_start(GTK_BOX(GTK_DIALOG(report_dialog->shell)->action_area),
> >                      report_dialog->btn_delete, TRUE, TRUE, 0);
> >   /* *INDENT-ON* */
> 
> You can also mark a larger region (a function or file).

then you're simply dejustifying the use of 'indent' at that point. Which
is just fine with me, I think that humans tend to format code better
given the proper guidelines. We also tend to understand the exceptions
to the rule like

  city_map_iterate(x,y) {

  } city_map_iterate_end;

which indent would happily (and wrongly for us anyway) do:

  city_map_iterate(x,y) {

  } 
  city_map_iterate_end;

which is pretty dumb, but hey, it is a machine after all.

Oh, and this is one of my favorites: 
(I added the "very_big" for illustration, without it, it's still bad)

  pdialog->very_big_name_shell = input_dialog_create(pdialog->shell,
                                    _("Name new preset"),
                                    _("What should we name the preset?"),
                                    default_name,
                                    (void *) cma_preset_add_callback_yes,
                                    (gpointer) pdialog,
                                    (void *) cma_preset_add_callback_no,
                                    (gpointer) pdialog);

which 'indent' mangles thusly:

  pdialog->very_big_name_shell = input_dialog_create(pdialog->shell,
                                                     _("Name new preset"),
                                                     _
                                                     ("What should we name the
preset?"),
                                                     default_name,
                                                     (void *)
                                                     
cma_preset_add_callback_yes,
                                                     (gpointer) pdialog,
                                                     (void *)
                                                     cma_preset_add_callback_no,
                                                     (gpointer) pdialog);


difficult to show in an email, but yes, it does wrap the lines over,
though not exactly this way...

> 
> 1) I don't thing that I will indent much GTK code in the next time.

I just used the gtk code because I am familiar with it and know where to
find the the examples. It just tends to be bad because it's got some
long function names. I imagine the xaw code or the client code is not
substantially different at present or in the near future.

If you decide not to indent some code, why indent the rest? people
should know by know that patches should be 'correctly' formatted and
don't have the privilege to bitch if a maintainer asks the submitter to
rework the patch so that lines don't wrap around for example. (now asking
to go beyond the stated style guide is another matter, but in that case,
indent wouldn't necessarily help)

> 2) What do other people think?

yes, I know that I said last time it would be nice if it were the last
style discussion...sorry. I lied.

-mike


[Prev in Thread] Current Thread [Next in Thread]