Passing Structs to function like in C
ag0aep6g via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Aug 12 10:53:12 PDT 2016
On 08/12/2016 07:33 PM, Cauterite wrote:
> Why would I not terminate a declaration with a semi-colon?
> Why should a declaration not end in a semi-colon just because the last
> token is a brace?
> Why should I not tell the lexer precisely where my declaration ends
> instead of relying on whatever other tokens floating around it not
> interfering?
The semicolon is just noise. You're not helping the lexer at all. It
goes by the braces, and doesn't see the semicolon as belonging to the
function declaration. The semicolon creates another, empty declaration.
This is accepted as well, and means the same:
----
;;;
void main() {}
;;;
----
> Why must every thread in this forum contain more posts regarding some
> irrelevant tangent than posts responding to the original topic?
This is a common mistake - more for structs, though, because of C
syntax. So I point it out so that you can learn that there's no point to
it in D, and so that others don't get the impression that it's the
proper syntax.
More information about the Digitalmars-d-learn
mailing list