Puzzled by this behavior

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Tue May 31 20:33:58 UTC 2022


On Tuesday, 31 May 2022 at 20:24:17 UTC, Steven Schveighoffer 
wrote:

> ```d
>     void foo() {bar(); }; // redeclares foo, not allowed
> ```

This ought to define what has already been declared. That is the 
purpose of a prototype. Calling this a "redeclaration" is 
arbitrary.


> would be the same with lambdas as:
>
> ```d
>     void delegate() foo; // declares foo and assigns it to null
>```

This declares and defines foo.

> You can't "assign" functions like you can lambdas. And D does 
> not allow redeclaring a symbol of any type in a specific scope.

Why do you call it "redeclaring" the signature is the same!? 
That's just an after-the-fact explanation. Calling this 
redeclaring doesn't follow from how prototypes in C works. If the 
signature is the same then you can do it as many times as you 
want.




More information about the Digitalmars-d mailing list