www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - function declaration in parameter list

reply "Jay Norwood" <jayn prismnet.com> writes:
On Saturday, 6 April 2013 at 14:50:50 UTC, Bruno Medeiros wrote:
 Interesting thread. I've been working on a hand-written D 
 parser (in Java, for the DDT IDE) and I too have found a slew 
 of grammar spec issues. Some of them more serious than the ones 
 you mentioned above. In same cases it's actually not clear, or 
 downright wrong what the grammar spec says. For example, here's 
 one off of my notes:

   void func(int foo() { } );

 The spec says that is parsable (basically a function 
 declaration in the parameter list), which makes no sense, and 
 DMD doesn't accept.
I'm wondering about the statement above, over in digitalmars.D thread, that the declaration makes no sense. http://dlang.org/expression.html#FunctionLiteral has void foo(int function(int) fp); Is/was void foo(int fp(int){}); intended to be accepted as an alternate form of that declaration?
Apr 30 2013
parent "evilrat" <evilrat666 gmail.com> writes:
On Wednesday, 1 May 2013 at 06:12:54 UTC, Jay Norwood wrote:
 On Saturday, 6 April 2013 at 14:50:50 UTC, Bruno Medeiros wrote:
 Interesting thread. I've been working on a hand-written D 
 parser (in Java, for the DDT IDE) and I too have found a slew 
 of grammar spec issues. Some of them more serious than the 
 ones you mentioned above. In same cases it's actually not 
 clear, or downright wrong what the grammar spec says. For 
 example, here's one off of my notes:

  void func(int foo() { } );

 The spec says that is parsable (basically a function 
 declaration in the parameter list), which makes no sense, and 
 DMD doesn't accept.
I'm wondering about the statement above, over in digitalmars.D thread, that the declaration makes no sense. http://dlang.org/expression.html#FunctionLiteral has void foo(int function(int) fp); Is/was void foo(int fp(int){}); intended to be accepted as an alternate form of that declaration?
look at signature void foo(int function(int) fp); it means "function foo which accepts another function which takes one int argument and return int value", and it perfectly fine. but this(void foo(int fp(int){});) is indeed doesn't work with DMD, so it may be just outdated stuff from D1, or someone's strange idea(may be inspired by something from java?) or anything like that.
May 01 2013