octave-maintainers
[Top][All Lists]
Advanced

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

Re: Octave coding conventions


From: John W. Eaton
Subject: Re: Octave coding conventions
Date: Mon, 13 Jan 2020 13:30:37 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

On 1/13/20 11:02 AM, Rik wrote:
How strictly do we want to enforce a line break after the return type in a
function declaration?  We mostly do this, but not always.  For example, in
Array.cc there is

template <typename T>
Array<T>
Array<T>::permute (const Array<octave_idx_type>& perm_vec_arg, bool inv) const

but also

template <typename T>
T * do_index (const T *src, T *dest, int lev) const

And do we want to enforce this convention in .cc files only or also .h
files?  For example, Array.h contains

octave_idx_type numel (void) const { return len; }

which is small and compact, but if enforcing the return type for a function
would become

octave_idx_type
numel (void) const { return len; }

There is no problem with declarations in a header file as that is a
separate switch to throw in astyle.

The original reason for writing the return type on a separate line was so that the function name would begin in column 1. Then you could easily grep for function declarations and definitions using an anchored pattern like ^FCN_NAME". But that doesn't work well for C++ member functions or any function inside a namespace declaration if we are indenting all code inside a namespace.

Recently, I've been putting the declaration all on one line if possible or splitting after the return type if the return type is long. I don't see that there is one rule that will fit all cases. I just try to do what looks best and makes the most sense for each case.

jwe



reply via email to

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