Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Nick Treleaven <[email protected]>
  • Loading branch information
2 people authored and Quirin Schroll committed Jun 27, 2024
1 parent a4ff66e commit 132cad9
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions spec/statement.dd
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ $(GNAME OpApplyParameter):
Above, `opApply` is matched both when `i` is and is not `ref`, so by using
a `ref` delegate parameter, both forms are supported.

Stating the type of the variable like in the first loop is optional,
Stating the type of the variable (as in the first loop) is optional,
as is showcased in the second loop, where the type is inferred.
)

Expand All @@ -770,10 +770,10 @@ $(GNAME OpApplyParameter):

$(P The $(D opApply) and $(D opApplyReverse) member functions can be overloaded.
Selection works similar to overload resolution by
comparing the number of `foreach` variables and number of parameters of `body` and,
if more than one overload remains unique overload,
matching the parameter types of `body` and each $(I ForeachType)
declared in the $(I ForeachStatement) when given.)
comparing the number of `foreach` variables with the number of parameters of `body` and,
if more than one overload remains,
matching each parameter of `body` against each $(I ForeachType)
declared in the $(I ForeachStatement).)

$(BEST_PRACTICE Overload apply functions only with delegates differing in number of parameters
to enable type inference for `foreach` variables.
Expand Down Expand Up @@ -828,20 +828,20 @@ $(CONSOLE

$(PANEL
The `scope` storage class on the `body` parameter means that the delegate does
not escape the scope of the apply function (an example would be assigning`body` to a
not escape the scope of the apply function (e.g. assigning `body` to a
global variable). If it cannot be statically guaranteed that `body` does not escape, a closure may
be allocated for it on the heap instead of the stack.
)

$(P $(B Important:) If apply functions catch any exceptions, ensure that those
$(P $(B Important:) If an apply function catches any exceptions, ensure that those
exceptions did not originate from the delegate. The user would expect
exceptions thrown from a `foreach` body to both terminate the loop, and propagate outside
the `foreach` body.
)

$(H4 $(LNAME2 template-op-apply, Template `opApply`))

$(P `opApply` and `opApplyReverse` can also be a function templates,
$(P `opApply` and `opApplyReverse` can also be function templates,
which can optionally infer the types of parameters based on the $(I ForeachStatement).
)

Expand Down

0 comments on commit 132cad9

Please sign in to comment.