fsharp / fsharp/fslang-suggestions

imply record labels from expressions

Open
#653 27 comments 49 reactions 0 assignees View on GitHub
approved-in-principle area: anonymous-records area: pattern-matching area: records
Dominant language
No language data
Stars
373
Forks
21
PR merge metrics
No merged PRs in 30d

Description

I propose we allow both records and anonymous records to imply record labels from a limited range of expressions, e.g. for anonymous records:

{| x.Name; x.Title |}

is the same as

{| Name=x.Name; Title=x.Title |}

The same would apply for records. The label names would be implied by a `expr.Name` lookup only.

It would be natural to do this at the same time as anonymous records.

The existing way of approaching this problem in F# is to write the label names explicitly.

## Pros and Cons

The advantages of making this adjustment to F# are succinctness

The disadvantages of making this adjustment to F# are you have to know the rule, and it makes the selection of type a little more implicit, especially in the case of records.

## Extra information

Estimated cost (XS, S, M, L, XL, XXL): M

Related suggestions: #207

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.