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

Jonathan Marler via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 19 13:23:16 PST 2015


On Monday, 19 January 2015 at 21:06:40 UTC, Alexey T. wrote:
> Better that next D version (next MAJOR version) can support such
> syntax. (Old syntax may be compatible too but "deprecated").
>
> What developers think..

I have a feeling you might get some strong opposition to this 
idea *Brace Yourself*.  However, I don't mind discussing new 
ideas.  I'm not familiar enough with the syntax grammar to say 
for sure whether or not this would make it easier to parse the 
language.  If it does, I wouldn't think it would make it much 
more simple.  One question is how would you declare a function 
pointer?

Current : void function() myfunction;
YourIdea: func void function() myfunction;

This seems a little odd/redundant. I suppose you could change the 
syntax to something like this:

func void myfunction();

But then you wouldn't be able to know if that was a function 
pointer or a function declaration.

I'll finish by saying that at first glance, I'm not sure if 
adding this extra keyword will help readability much.  I've never 
really had problems distinguishing between functions and other 
things.  That being said, maybe I've been programming in C-like 
languages too much so take that with a grain of salt.


More information about the Digitalmars-d mailing list