-
Notifications
You must be signed in to change notification settings - Fork 602
-
Notifications
You must be signed in to change notification settings - Fork 602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accept readonly array inputs for all functions/methods that don't need to mutate their data #5831
Labels
Comments
lionel-rowe
added a commit
to lionel-rowe/std
that referenced
this issue
Aug 26, 2024
lionel-rowe
added a commit
to lionel-rowe/std
that referenced
this issue
Aug 26, 2024
lionel-rowe
added a commit
to lionel-rowe/std
that referenced
this issue
Aug 26, 2024
This seems like good practice. +1 from me. |
iuioiua
added
feedback welcome
We want community's feedback on this issue or PR
good first issue
Good for newcomers
PR welcome
A pull request for this issue would be welcome
and removed
feedback welcome
We want community's feedback on this issue or PR
labels
Aug 26, 2024
iuioiua
pushed a commit
that referenced
this issue
Aug 27, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Further to #5734
Is your feature request related to a problem? Please describe.
Currently, passing data marked
as const
to various@std
functions/methods fails type checking, even though the passed data is never modified by the function in question.For example,
msgpack/encode
:Describe the solution you'd like
Mark all array arguments as
readonly
unless they are mutated by the function in question. The readonly-ness then becomes explicitly part of the contract of the function, hence changing the implementation such that it mutates such arrays would be a breaking change (typically it'd already be a breaking change though, given that consumers typically don't expect functions to mutate their inputs unless such mutation is explicitly the purpose of the function).Describe alternatives you've considered
Using the same example data as above:
The text was updated successfully, but these errors were encountered: