-
Notifications
You must be signed in to change notification settings - Fork 448
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
Use FINAL declarations for immutable variables #299
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have suggested a change to address the subtlety of FINAL
that it does not prevent changes in general. It merely prevents changes in unexpected places.
Co-authored-by: N2oB6n-SAP <109298321+N2oB6n-SAP@users.noreply.github.com>
Now here's a problem: I find this to be a major downside of the new keyword. Does anyone know if there's a workaround or a setting for the debugger? If not, then I'm personally quite conflicted about the new rule. I've converted the pull request to a draft until further clarification took place. |
One comment form the ABAP Debugger perspective: |
The issue with While it may be tempting to think about The following code is syntax-error free, but produces a short dump at runtime: final(var) = 1.
assign var to field-symbol(<var>).
<var> = 11. Changing the data declaration to use This is probably not what you expect if you are used to thinking about immutability as a compile-time property of bindings (like const variables in Javascript or non-mut variables in Rust), even though the documentation of In the example above it is easy to understand why the dump happens once you realize final(var) = 1.
not_my_method( ref #( var ) ). If So while I think a recommendation in the spirit of "Use |
Great comment. I am closing this pull request and pointed the issue to it. |
Fixes #285.
I've added the new rule and changed all examples in which it was obvious that a variable is never reassigned.