Like Go/Rust, why not to have "func" keyword before function declaration

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 19 13:58:04 PST 2015


On Monday, January 19, 2015 20:51:02 Alexey T. via Digitalmars-d wrote:
> Will be much easier to read Source, if func declarataion begins
> with keyword. "def" of "func". e.g.
>
> func myName(params.....): typeOfResult;
> or
> func myName(params...) -> typeOfResult;
>
> easier to read and PARSE. Next D version may allow--with
> compatability of old syntad (C like where typeOfResult is 1st id).

I don't recall ever having any problem with the C/C++ syntax that D uses.
The major problem was with the function pointer syntax, and we already fixed
that. I really don't see how changing the function signature syntax in D
would help anything, and it would force all existing code to be changed (be
it immediately or just when the compatability flag finally goes anyway).
Sometimes, syntax improvements are worth it, but in general, it's just not
worth messing with the syntax unless the language is still in flux enough
that you don't care at all about breaking existing code. So, even if your
suggestion were objectively better (and it really isn't), we probably
wouldn't go with it at this point.

- Jonathan M Davis



More information about the Digitalmars-d mailing list