digitalmars.D.bugs - [Issue 2002] New: Add keyword for a function definition
- d-bugmail puremagic.com (53/53) Apr 16 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2002
- d-bugmail puremagic.com (6/6) Apr 26 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2002
- d-bugmail puremagic.com (11/11) Apr 26 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2002
http://d.puremagic.com/issues/show_bug.cgi?id=2002 Summary: Add keyword for a function definition Product: D Version: unspecified Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: gaboonviper gmx.net 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 --
Apr 16 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2002 This proposal is too fresh from the NG. It had little discussion, and received little to no support (other than yourself). vote- --
Apr 26 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2002 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 --
Apr 26 2008