Skip to content

Commit 61ff3af

Browse files
authored
[spec/function] Improve prototype docs (#3840)
Rename subheading. Mention linkage. Link to `.di` files.
1 parent fdfa977 commit 61ff3af

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

spec/function.dd

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ $(GNAME FuncDeclaratorSuffix):
2222
$(GLINK2 template, TemplateParameters) $(GLINK Parameters) $(GLINK MemberFunctionAttributes)$(OPT) $(GLINK2 template, Constraint)$(OPT)
2323
)
2424

25-
* A *FuncDeclaration* with a $(GLINK FunctionBody) is called a *function definition*.
25+
* A *FuncDeclaration* with a function body is called a
26+
$(RELATIVE_LINK2 function-bodies, function definition).
27+
* A *FuncDeclaration* without a function body is called a
28+
$(RELATIVE_LINK2 function-declarations, function prototype).
2629
* A *FuncDeclaration* with *TemplateParameters* defines a
2730
$(DDSUBLINK spec/template, function-templates, function template).
2831

@@ -135,7 +138,7 @@ $(LEGACY_LNAME2 FunctionLiteralBody)
135138
This syntax also applies for $(DDSUBLINK spec/expression, function_literals, function literals).)
136139

137140

138-
$(H3 $(LNAME2 function-declarations, Functions without Bodies))
141+
$(H3 $(LNAME2 function-declarations, Function Prototypes))
139142

140143
$(GRAMMAR
141144
$(GNAME MissingFunctionBody):
@@ -144,16 +147,23 @@ $(GNAME MissingFunctionBody):
144147
$(GLINK FunctionContracts)$(OPT) $(GLINK InOutStatement)
145148
)
146149

147-
$(P Functions without bodies:)
150+
$(P Function declarations with a *MissingFunctionBody*, e.g.:)
148151

149152
---
150153
int foo();
151154
---
152155

153-
$(P that are not declared as $(D abstract) are expected to have their implementations
156+
$(P that are not declared as $(DDSUBLINK spec/class, abstract, `abstract`)
157+
are expected to have their implementations
154158
elsewhere, and that implementation will be provided at the link step.
155159
This enables an implementation of a function to be completely hidden from the user
156160
of it, and the implementation may be in another language such as C, assembler, etc.
161+
Typically a function prototype would have non-`extern(D)`
162+
$(DDSUBLINK spec/attribute, linkage, linkage).
163+
)
164+
165+
$(P A function prototype can have `extern(D)` linkage.
166+
This is useful for $(DDSUBLINK dmd, interface-files, D interface files).
157167
)
158168

159169

0 commit comments

Comments
 (0)