diff options
| author | Entropy Lost <rouli.freeman@gmail.com> | 2025-01-14 16:27:32 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-14 08:27:32 -0800 |
| commit | 11575d21934caef511147b279c7495df3efa0ba3 (patch) | |
| tree | 01081fb0e76b45632c4a908113ce07841302625b /docs/user-guide | |
| parent | 4da52b65ac04251ab52d713fa28146f76a84446c (diff) | |
Fix inaccurate documentation in member function mutability. (#6065)
* Fix inaccurate documentation in member function mutability.
* Change throw to result in for specificity.
---------
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'docs/user-guide')
| -rw-r--r-- | docs/user-guide/03-convenience-features.md | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/docs/user-guide/03-convenience-features.md b/docs/user-guide/03-convenience-features.md index e6b337eed..29e8fd2aa 100644 --- a/docs/user-guide/03-convenience-features.md +++ b/docs/user-guide/03-convenience-features.md @@ -149,7 +149,7 @@ int rs = foo.staticMethod(a,b); ### Mutability of member function -For GPU performance considerations, the `this` argument in a member function is immutable by default. If you modify the content in `this` argument, the modification will be discarded after the call and does not affect the input object. If you intend to define a member function that mutates the object, use `[mutating]` attribute on the member function as shown in the following example. +For GPU performance considerations, the `this` argument in a member function is immutable by default. Attempting to modify `this` will result in a compile error. If you intend to define a member function that mutates the object, use `[mutating]` attribute on the member function as shown in the following example. ```hlsl struct Foo @@ -159,14 +159,14 @@ struct Foo [mutating] void setCount(int x) { count = x; } - void setCount2(int x) { count = x; } + // This would fail to compile. + // void setCount2(int x) { count = x; } } void test() { Foo f; - f.setCount(1); // f.count is 1 after the call. - f.setCount2(2); // f.count is still 1 after the call. + f.setCount(1); // Compiles } ``` |
