Skip to content

Commit d2aa5b6

Browse files
committed
Remove confusing usage of terminology "block of a function"
It's usually referred to as the "body" of the function, and I'm making it consistent here. In order to emphasize the nature of the body of a block, occasionally "body block" is used. (One instance of "body block" was already present.) This particularly improves the sentence that used to explain "The block of a function is conceptually wrapped in a block that binds ..." which was just plain confusing.
1 parent d876ba2 commit d2aa5b6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/items/functions.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
> [^fn-param-2015]: Function parameters with only a type are only allowed
4343
> in an associated function of a [trait item] in the 2015 edition.
4444
45-
A _function_ consists of a [block], along with a name, a set of parameters, and an output type.
45+
A _function_ consists of a [block] (that's the _body_ of the function),
46+
along with a name, a set of parameters, and an output type.
4647
Other than a name, all these are optional.
4748
Functions are declared with the keyword `fn`.
4849
Functions may declare a set of *input* [*variables*][variables] as parameters, through which the caller passes arguments into the function, and the *output* [*type*][type] of the value the function will return to its caller on completion.
@@ -79,8 +80,8 @@ parameter may have an optional identifier, such as `args: ...`.
7980

8081
## Function body
8182

82-
The block of a function is conceptually wrapped in a block that binds the
83-
argument patterns and then `return`s the value of the function's block. This
83+
The body block of a function is conceptually wrapped in another block that first binds the
84+
argument patterns and then `return`s the value of the function's body. This
8485
means that the tail expression of the block, if evaluated, ends up being
8586
returned to the caller. As usual, an explicit return expression within
8687
the body of the function will short-cut that implicit return, if reached.
@@ -325,7 +326,7 @@ responsibility to ensure that.
325326
## Attributes on functions
326327

327328
[Outer attributes][attributes] are allowed on functions. [Inner
328-
attributes][attributes] are allowed directly after the `{` inside its [block].
329+
attributes][attributes] are allowed directly after the `{` inside its body [block].
329330

330331
This example shows an inner attribute on a function. The function is documented
331332
with just the word "Example".

0 commit comments

Comments
 (0)