Make with
more useful when modifying trees
#4849
Unanswered
TonyValenti
asked this question in
Language Ideas
Replies: 1 comment
-
I would prefer alternative 2. Alternative 1 has some issues imo: var V2 = V1 with {
M2 = M2 with {
Id = 22
},
M3 = M3 with {
M2 = M3 // Could cause confusion about what M3 refers to here.
}
}; |
Beta Was this translation helpful? Give feedback.
0 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.
-
Suppose I have the following record:
And I create an instance like so:
Today, if I want to modify different areas of the tree, I would use code like this:
This is verbose because:
I propose the following two alternatives as more concise shorthands:
Alternative 1
A member with the same name as the current member is always in scope (In order to preserve compatibility with other code, it could not hide another variable with the same name).
Alternative 2
Allow
with
ing a member directly.Beta Was this translation helpful? Give feedback.
All reactions