[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Octave coding style questions
From: |
Mike Miller |
Subject: |
Re: Octave coding style questions |
Date: |
Sun, 12 Jan 2020 13:02:01 -0800 |
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)
> 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++.
> 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
{
Cheers,
--
mike
signature.asc
Description: PGP signature
- Octave coding style questions, Rik, 2020/01/12
- Re: Octave coding style questions,
Mike Miller <=
- Re: Octave coding style questions, Kai Torben Ohlhus, 2020/01/13
- Re: astyle configuration, Rik, 2020/01/13
- Re: astyle configuration, Gene Harvey, 2020/01/13
- Re: astyle configuration, Rik, 2020/01/13
- Re: astyle configuration, Kai Torben Ohlhus, 2020/01/14
- Re: astyle configuration, John W. Eaton, 2020/01/14
- Re: astyle configuration, Gene Harvey, 2020/01/14