Like C and C++, D doesn't have a keyword for function definitions. In C you can get away with it, since it's a simple language with few possibilities. The complexity of the C++ and D languages make this approach unsuitable.
Adding a function definition keyword makes the language easier to read. Consider the following function definition:
int doSomething(int someParam)
{
...
}
against
function int doSomething(int someParam)
{
...
}
For the second function definition it's immediatly clear that we're declaring a function here. No need for second glances, this is definitely a function. The first one on the other is not as intuitive, except perhaps for C/C++ programmers.
While for a simple function the readability improvement may be marginal. When we consider storage classes and type modifiers, the keyword's influence is much bigger.
private static const int doSomething(int someParam){}
vs
private static const function int doSomething(int someParam){}
In the first declaration it's a game of 'what belongs to who', whereas the declaration with the function keyword is a lot more expressive. And with some good syntax highlighting its effect will be even larger.
It's also more consistent with the rest of D syntax. Especially if you'd ommit the void type, which the keyword would make possible.
struct X;
class X;
template X();
function X();
macro X();
So basically using a function definition keyword will decrease the learning curve needed for D. It will increase the readability of D code. And it could possibly make it easier to parse.
I hope you will consider implementing it.
Cheers,
Boyd van Oosterhout
Comment #1 by bruno.do.medeiros+deebugz — 2008-04-26T12:58:28Z
This proposal is too fresh from the NG. It had little discussion, and received little to no support (other than yourself).
vote-
Comment #2 by gaboonviper — 2008-04-26T13:24:06Z
Yes, that's why I posted it here. On the newsgroup there wasn't much of a reaction. What reaction there was, was moderately positive, not too enthousiastic though.
Here it can either be permanently rejected, left alone until more pressing matters are resolved, or discussed on a more longterm basis. The newsgroup simply isn't suitable for that.
Cheers,
Boyd
Comment #3 by lt.infiltrator — 2014-03-18T21:36:17Z
If you are really after this sort of style, you can use the existing function syntax:
int function(int x) doSomething = {
...
};