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: Mike Kaufman <mkaufman@xxxxxxxxxxxxxx>
Cc: Freeciv-Dev <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: possible addition to README.coding_style
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 4 Feb 2002 09:10:03 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Sun, Feb 03, 2002 at 04:22:55PM -0600, Mike Kaufman wrote:
> 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;

I completely agree that this a big shortcoming of indent.

> 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...

But you can't solve this problem in general. Just make the start of
the line a little bigger and then also you as human have to produce
ugly versions.

> > 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.

AFAIK the GTK is one of the main areas with this problem. IMHO because
of the cast functions (GTK_*).

> 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)

If patch submitters say that I shouldn't touch their code I won't (and
will be bitchy).

> > 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.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "We've all heard that a million monkeys banging on a million typewriters
  will eventually reproduce the entire works of Shakespeare.
  Now, thanks to the Internet, we know this is not true."


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