You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I propose we implement a feature that extends the way in which field names of anonymous records are expressed. Currently, the field names have to be written explicitly, followed by the value assignement. Instead, field names could be implied by the name of the value assignement expression.
Example:
typeFoo={ id:int; name:string }letfoo={ id=42; name="Hans"}letbar=4711// I suggest we writeletfooBar={| foo.name; bar;|}(* instead oflet fooBar = {| name=foo.name; bar=bar |}*)
Implied names should work at least for:
Record fields
Class / struct fields and properties
identifiers (let; dynamic operator)
evaluated functions (propably too implicit; better explicit naming?)
C# has a similar feature.
Pros and Cons
The advantages of making this adjustment to F# is the removal of redundant information that has to be typed in by the user. Especially when working with types that have a lot of properties, this feature can improve the anonymous records experience.
When working interactively with FSI, shortcuts and ease of use are important for an uninterrupted workflow. Quick transformations of data is a key point, and "subtracting" properties from large types is an often performed use case:
query {for x in context.Shipments do// do some stuff...
select {| x.id; x.name; x.shipmentCode.whatever |}}|> printAsTable
The disadvantages of making this adjustment to F# are more shortcuts a
Extra information
{| foo.name; bar; |} should equal {| name = foo.name; bar = bar; |} .
Estimated cost (XS, S, M, L, XL, XXL): I've never worked in FSC project, but I guess compared to other features maybe S?
This is not something which has obviously "already been decided" in previous versions of F#. If you're questioning a fundamental design decision that has obviously already been taken (e.g. "Make F# untyped") then please don't submit it.
Please tick all that apply:
This is not a breaking change to the F# language design
I or my company would be willing to help implement and/or test this
The text was updated successfully, but these errors were encountered:
Implied field names for anonymous records
I propose we implement a feature that extends the way in which field names of anonymous records are expressed. Currently, the field names have to be written explicitly, followed by the value assignement. Instead, field names could be implied by the name of the value assignement expression.
Example:
Implied names should work at least for:
C# has a similar feature.
Pros and Cons
The advantages of making this adjustment to F# is the removal of redundant information that has to be typed in by the user. Especially when working with types that have a lot of properties, this feature can improve the anonymous records experience.
When working interactively with FSI, shortcuts and ease of use are important for an uninterrupted workflow. Quick transformations of data is a key point, and "subtracting" properties from large types is an often performed use case:
The disadvantages of making this adjustment to F# are more shortcuts a
Extra information
{| foo.name; bar; |}
should equal{| name = foo.name; bar = bar; |}
.Estimated cost (XS, S, M, L, XL, XXL): I've never worked in FSC project, but I guess compared to other features maybe S?
Related suggestions: #207
Affidavit (please submit!)
Please tick this by placing a cross in the box:
Please tick all that apply:
The text was updated successfully, but these errors were encountered: