Skip to content

Conversation

@vzarytovskii
Copy link
Member

@vzarytovskii vzarytovskii commented Aug 4, 2021

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:

  • Lexer/parser with- support for anonymous records expression.
  • Actual logic to remove fields when creating new AnonRecd.
  • Tests

@vzarytovskii vzarytovskii marked this pull request as draft August 4, 2021 14:03
@vzarytovskii vzarytovskii changed the title WIP: 'with-' keyword support for anonymous records WIP: with- keyword support for anonymous records Aug 4, 2021
@vzarytovskii vzarytovskii self-assigned this Aug 4, 2021
isStruct: bool *
copyInfo:(SynExpr * BlockSeparator) option *
recordFields:(Ident * SynExpr) list *
copyInfo: (SynExpr * BlockSeparator) option *
Copy link
Contributor

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 |}
Copy link
Member

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

Copy link
Member

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.

Copy link
Member

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.

@KevinRansom
Copy link
Contributor

Closing, two years without attention, please reopen if you want to work on completiong this.

Thanks

Kevin

@vzarytovskii
Copy link
Member Author

Gonna close it for now, needs more thinking in regards of spread operator

@vzarytovskii vzarytovskii deleted the without-anonrecd branch May 22, 2023 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants