Skip to content

Commit da65f25

Browse files
committed
Explain return types and string[] parameter
1 parent 8e92e6d commit da65f25

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

spec/function.dd

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2962,8 +2962,8 @@ $(H2 $(LNAME2 main, $(D main()) Function))
29622962

29632963
$(GRAMMAR
29642964
$(GNAME MainFunction):
2965-
$(GLINK MainReturnDecl) main $(D $(LPAREN)$(RPAREN)) $(GLINK2 statement, BlockStatement)
2966-
$(GLINK MainReturnDecl) main $(D $(LPAREN)string[] args$(RPAREN)) $(GLINK2 statement, BlockStatement)
2965+
$(GLINK MainReturnDecl) $(D main$(LPAREN)$(RPAREN)) $(GLINK2 statement, BlockStatement)
2966+
$(GLINK MainReturnDecl) $(D main$(LPAREN)string[]) $(GLINK_LEX Identifier)$(D $(RPAREN)) $(GLINK2 statement, BlockStatement)
29672967

29682968
$(GNAME MainReturnDecl):
29692969
$(D void)
@@ -2972,6 +2972,18 @@ $(H2 $(LNAME2 main, $(D main()) Function))
29722972
$(RELATIVE_LINK2 auto-functions, $(D auto))
29732973
)
29742974

2975+
$(UL
2976+
$(LI If `main` returns `void`, the OS will receive a zero value on success.)
2977+
$(LI If `main` returns `void` or `noreturn`, the OS will receive a non-zero
2978+
value on abnormal termination, such as an uncaught exception.)
2979+
$(LI If `main` is declared as `auto`, the inferred return type must be
2980+
one of `void`, `int` and `noreturn`.)
2981+
)
2982+
2983+
$(P If the $(D string[]) parameter is declared, the parameter will hold any
2984+
arguments passed to the program by the OS. The first argument is typically
2985+
the executable name, followed by any command-line arguments.)
2986+
29752987
$(P The main function must have D linkage.)
29762988

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

0 commit comments

Comments
 (0)