octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Octave coding style questions


From: John W. Eaton
Subject: Re: Octave coding style questions
Date: Sun, 12 Jan 2020 23:40:34 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

On 1/12/20 4:02 PM, Mike Miller wrote:
On Sun, Jan 12, 2020 at 10:38:26 -0800, Rik wrote:
astyle would like to remove the extra indent and make this

enum color
{
   RED,
   GREEN,
   BLUE
};

I don't think it particularly matters, and would prefer to let astyle
correct this and then stop harassing me.  Are there any useful arguments
agains this change?

No, and this change is consistent with the GNU standards
(https://www.gnu.org/prep/standards/html_node/Formatting.html#index-enum-types_002c-formatting)

This change is fine with me, though Emacs CC mode with the gnu style appears to indent the enum block by default but it shouldn't be too hard to change that.

On a related note, how should class definitions being handled?  In some
cases we use the C++ keyword followed immediately by the class name, and in
other cases "class" appears by itself followed by the name of the class on
it's own line.  This is vaguely similar to the way we define functions
where the return value appears first on its own line followed by the name
of the function.  Examples:

Style #1
class callback_props
{

Style #2
class
callback_event
{

I think the first choice is more sensible here. The GNU C style does not
recommend splitting after the keyword "enum" or "struct" for example,
and "class" is in the same family as "enum" and "struct" in C++.

Yes, style #1 seems better to me as well.

A second decision is whether parent classes  should appear on the line with
the name of the class, or also on their own

Style #1
class
callback_event : public base_graphics_event
{

Style #2
class
callback_event
   : public base_graphics_event
{

I think the first choice is more sensible here, with the "class" keyword
also on the same line

     class callback_event : public base_graphics_event
     {

When the class names are long enough to warrant folding, then colon
makes sense as a fold point

     class exceptionally_long_derived_class_name
       : public exceptionally_long_base_class_name
     {

I agree.

jwe



reply via email to

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