fsharp / fsharp/fslang-suggestions

imply record labels from expressions

Offen
#653 27 Kommentare 49 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
approved-in-principle area: anonymous-records area: pattern-matching area: records
Vorherrschende Sprache
Keine Sprachdaten
Sterne
373
Forks
21
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Überprüfe die im Issue vorgeschlagene Syntax für anonyme Records und Records und lies anschließend den zugehörigen Vorschlag #207 sowie den Diskussionsverlauf auf ungelöste Einwände. Ein vollständiger Beitrag würde ein abgestimmtes Design für die Inferenz von Labels, die nur auf expr.Name basieren, und deren Zusammenspiel mit der Auswahl des Record-Typs erfordern.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Bereich
compilers
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.