This question is 99% likely to be closed for being opinion based, but I'll try to give an objective stab as to what might have motivated this choice.
Most C like languages have that format, of Type identifier(params)
. Undeniably, this is draws from C's original design. C++, Java, C#, all follow this style.
This style has significant issues for non-trivial types, as it makes it hard to pick out the method name without first reading through the type and parsing it, mentally. Consider this pretty typical Java method:
...
public static final Map<String, Array<MyGenericType<Foo, Bar>>> myMethodName(Type param) { ... }
...
The method name, myMethodName
, is halfway across the screen (assuming you follow a generous 120 character ruled code standard, and not an 80 char one). It's really quite silly.
Style guides have picked up on this, and for many C languages, it's advised to put the name on a new line, with all type information, access specifiers, etc, on the previous line. This is especially prevalent in C++.
Consider this real example from the Boost
library in C++.
template <class A1, class A2, class A3, class A4, class A5, class A6>
inline typename normalise<policy<>, A1, A2, A3, A4, A5, A6>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&)
{
typedef typename normalise<policy<>, A1, A2, A3, A4, A5, A6>::type result_type;
return result_type();
}
Many would suggest it be written like this:
template <class A1, class A2, class A3, class A4, class A5, class A6>
inline typename normalise<policy<>, A1, A2, A3, A4, A5, A6>::type
auto make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&)
{
typedef typename normalise<policy<>, A1, A2, A3, A4, A5, A6>::type result_type;
return result_type();
}
but in any case, the C++ teamed realized this madness, and would now allow this to be written as:
template <class A1, class A2, class A3, class A4, class A5, class A6>
make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&) -> inline typename normalise<policy<>, A1, A2, A3, A4, A5, A6>::type
{
typedef typename normalise<policy<>, A1, A2, A3, A4, A5, A6>::type result_type;
return result_type();
}