Improved "with keyword" with nested assignment / referential paths #8289
Unanswered
dellamonica
asked this question in
Language Ideas
Replies: 1 comment 5 replies
-
See: #5176 |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Make the with keyword more powerful by allowing it to operate on nested properties.
For instance, let A be a record type containing another record Type B under property PropB.
This would be lowered to
A related feature that could be useful is to include a reference to the instance being modified within the brackets.
Though arguably even better (for such cases) would be
The this inside the brackets refer to the instanceOfA before assignment. Although in principle it could break some code where this is being used to refer to the instance of the containing class/struct, this type of code is probably very rare (indeed, there are very few cases where one needs to type out "this" when accessing local properties). Alternatively, the compiler could be smart enough to detect ambiguities and issue a warning, falling back to this referring to the containing type as legacy behavior.
Beta Was this translation helpful? Give feedback.
All reactions