-
Notifications
You must be signed in to change notification settings - Fork 826
WIP: with-
keyword support for anonymous records
#11911
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
Conversation
with-
keyword support for anonymous records
@@ -477,8 +477,9 @@ type SynExpr = | |||
|
|||
| AnonRecd of | |||
isStruct: bool * | |||
copyInfo:(SynExpr * BlockSeparator) option * | |||
recordFields:(Ident * SynExpr) list * | |||
copyInfo: (SynExpr * BlockSeparator) option * |
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.
Could we have the range of the with-
keyword in the tree as well?
This would be useful for Fantomas if the code has a comment after the with-
for example.
type A = { X: int; Y: int }
let a = { X = 1; Y = 2 }
let b = {| a with- // foo
Y |}
Fsx """ | ||
type A = { X: int } | ||
let a = { X = 1 } | ||
let b = {| a with- X |} |
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.
This would be quite a use case for #6941
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 would expect a with-
to always remove the field. When the fields already present are controlled elsewhere, I would want this to be a guarantee.
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.
The flow of fields should allow an empty state where more fields can be added later.
Closing, two years without attention, please reopen if you want to work on completiong this. Thanks Kevin |
Gonna close it for now, needs more thinking in regards of spread operator |
This is pretty much a WIP or an experiment of adding a without (or
with-
) keyword support for anonymous records.Note: things may change (e.g. keyword itself (as many people don't like
with-
), implementation details, language switch, etc).RFC: https://github.com/fsharp/fslang-design/blob/main/RFCs/FS-1072-without-anonymous-records.md
Discussion: fsharp/fslang-design#616
Things to be done:
with-
support for anonymous records expression.