From f15317588dfdcb16d3816ef1b90d69eec7bbf521 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Thu, 23 Nov 2023 10:54:00 +0000 Subject: [PATCH] Add note for the purpose of input parameters Fixes #845. I'm not at all convinced of the tone or precision of this - it's effectively a straw man for further discussion. --- standard/classes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/standard/classes.md b/standard/classes.md index 6d687703e..471a92ead 100644 --- a/standard/classes.md +++ b/standard/classes.md @@ -2156,6 +2156,8 @@ Input parameters are not allowed on functions declared as an iterator ([§15.14] In a method that takes input parameters, it is possible for multiple names to represent the same storage location. +> *Note*: The primary purpose of input parameters is for efficiency. When the type of a method parameter is a large struct (in terms of memory requirements), it is useful to be able to avoid copying the whole value of the argument when calling the method. Input parameters allow methods to refer to existing values in memory, while providing protection against unwanted changes to those values. *end note* + #### 15.6.2.4 Reference parameters A parameter declared with a `ref` modifier is a reference parameter. A reference parameter is a local reference variable ([§9.7](variables.md#97-reference-variables-and-returns)) that gets its initial referent from the corresponding argument supplied in the method invocation.