Skip to content

Commit c386b33

Browse files
authored
Fix formatting and wording
1 parent 3f7522a commit c386b33

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

spec/function.dd

+31-29
Original file line numberDiff line numberDiff line change
@@ -3414,30 +3414,31 @@ $(H3 $(LNAME2 anonymous, Anonymous Functions and Anonymous Delegates))
34143414
$(P See $(GLINK2 expression, FunctionLiteral)s.
34153415
)
34163416

3417-
$(H2 $(LNAME2 main, $(D main()) Function))
3417+
$(H2 $(LNAME2 main, The $(D main) Function))
34183418

3419-
$(P For console programs, $(D main()) serves as the entry point.
3419+
$(P For console programs, the $(D main) function serves as the entry point.
34203420
It gets called after all the $(DDSUBLINK spec/module, staticorder, module initializers)
34213421
are run, and after any $(DDLINK spec/unittest, Unit Tests, unittests) are run.
34223422
After it returns, all the module destructors are run.
3423-
$(D main()) must be declared as follows:
3423+
The $(D main) function typically is declared as follows:
34243424
)
34253425

3426-
$(GRAMMAR
3427-
$(GNAME MainFunction):
3428-
$(GLINK MainReturnDecl) $(D main$(LPAREN)$(RPAREN)) $(GLINK2 statement, MainFunctionBody)
3429-
$(GLINK MainReturnDecl) $(D main$(LPAREN)string[]) $(GLINK_LEX Identifier)$(D $(RPAREN)) $(GLINK2 statement, MainFunctionBody)
3426+
$(INFORMATIVE_GRAMMAR
3427+
$(GNAME MainFunction):
3428+
$(GLINK MainReturnDecl) $(D main) $(LPAREN) $(RPAREN) $(GLINK FunctionBody)
3429+
$(GLINK MainReturnDecl) $(D main) $(LPAREN) $(D string) $(D [) $(D ]) $(GLINK_LEX Identifier)$(OPT) $(RPAREN) $(GLINK FunctionBody)
34303430

3431-
$(GNAME MainReturnDecl):
3432-
$(D void)
3433-
$(D int)
3434-
$(GLINK2 type, noreturn)
3435-
$(RELATIVE_LINK2 auto-functions, $(D auto))
3431+
$(GNAME MainReturnDecl):
3432+
$(D void)
3433+
$(D int)
3434+
$(GLINK2 type, noreturn)
3435+
$(RELATIVE_LINK2 auto-functions, $(D auto))
3436+
$(GLINK_LEX Identifier)
34363437

3437-
$(GNAME MainFunctionBody):
3438-
$(GLINK ShortenedFunctionBody)
3439-
$(GLINK SpecifiedFunctionBody)
3440-
)
3438+
$(GNAME MainFunctionBody):
3439+
$(GLINK ShortenedFunctionBody)
3440+
$(GLINK SpecifiedFunctionBody)
3441+
)
34413442

34423443
$(UL
34433444
$(LI If `main` returns `void`, the OS will receive a zero value on success.)
@@ -3447,35 +3448,36 @@ $(H2 $(LNAME2 main, $(D main()) Function))
34473448
one of `void`, `int` and `noreturn`.)
34483449
)
34493450

3450-
$(P If the $(D string[]) parameter is declared, the parameter will hold
3451-
arguments passed to the program by the OS. The first argument is typically
3451+
$(P If the parameter is declared, it will hold
3452+
arguments passed to the program by the OS. The index-0 element is typically
34523453
the executable name, followed by any command-line arguments.)
34533454

34543455
$(NOTE The runtime can remove any arguments prefixed `--DRT-`.)
34553456

3456-
$(NOTE The aforementioned return / parameter types may be annotated with $(D const),
3457-
$(D immutable). They may also be replaced by $(D enum)'s with matching base types.)
3457+
$(NOTE The aforementioned return / parameter types may be annotated with $(D const) or
3458+
$(D immutable), or carry $(GLINK ParameterAttributes).
3459+
They may also be replaced by $(D enum) types with matching base types.)
34583460

34593461
$(P The main function must have D linkage.)
34603462

34613463
$(P Attributes may be added as needed, e.g. `@safe`, `@nogc`, `nothrow`, etc.)
34623464

3463-
$(H3 $(LNAME2 betterc-main, $(D extern(C) main()) Function))
3465+
$(H2 $(LNAME2 betterc-main, $(D extern(C)) $(D main) Function))
34643466

34653467
$(P Programs may define an $(D extern(C) main) function as an alternative to the
34663468
standard $(RELATIVE_LINK2 main, entry point). This form is required for
34673469
$(DDLINK spec/betterc, Better C, $(B BetterC)) programs.)
34683470

3469-
$(P A C $(D main) function must be declared as follows:)
3471+
$(P A C $(D main) function is typically declared as follows:)
34703472

3471-
$(GRAMMAR
3472-
$(GNAME CMainFunction):
3473-
$(D extern (C)) $(GLINK MainReturnDecl) $(D main$(LPAREN)$(GLINK CmainParameters)$(OPT)$(RPAREN)) $(GLINK2 statement, BlockStatement)
3473+
$(INFORMATIVE_GRAMMAR
3474+
$(GNAME CMainFunction):
3475+
$(D extern) $(LPAREN) $(D C) $(RPAREN) $(GLINK MainReturnDecl) $(D main) $(LPAREN) $(GLINK CMainParameters)$(OPT) $(RPAREN) $(GLINK2 statement, BlockStatement)
34743476

3475-
$(GNAME CmainParameters):
3476-
$(D int) $(GLINK_LEX Identifier), $(D char**) $(GLINK_LEX Identifier)
3477-
$(D int) $(GLINK_LEX Identifier), $(D char**) $(GLINK_LEX Identifier), $(D char**) $(GLINK_LEX Identifier)
3478-
)
3477+
$(GNAME CMainParameters):
3478+
$(D int) $(GLINK_LEX Identifier)$(OPT) $(D ,) $(D char**) $(GLINK_LEX Identifier)$(OPT)
3479+
$(D int) $(GLINK_LEX Identifier)$(OPT) $(D ,) $(D char**) $(GLINK_LEX Identifier)$(OPT) $(D ,) $(D char**) $(GLINK_LEX Identifier)$(OPT)
3480+
)
34793481

34803482
$(P When defined, the first two parameters denote a C-style array (length + pointer)
34813483
that holds the arguments passed to the program by the OS. The third parameter is a POSIX

0 commit comments

Comments
 (0)