Skip to content

Quotations: Expr.NewTuple missing options for struct tuples #7914

Closed

Description

@eiriktsarpalis

Is your feature request related to a problem? Please describe.

Quotations seem to be missing a way to construct struct tuples. The Expr.NewTuple constructor will always assume reference tuples. There is no clear workaround, except for splicing into quotation literals (e.g. <@ struct(%x, %y) @>), but that only really works when the types and arity are fixed.

On the other hand, the Patterns.NewTuple active pattern will readily recognize both struct and reference tuple constructors, however the two kinds are not distinguished unless the user performs additional reflection tests on their own.

Describe the solution you'd like

I propose the addition of an Expr.NewStructTuple : Expr list -> Expr constructor. It's a trivial addition which would require adding an isStruct boolean parameter to this internal function.

At the same time, it would probably make sense to expose an equivalent Patterns.NewStructTuple active pattern. To avoid breaking changes, the NewTuple active pattern would still have to recognize struct tuple types.

Activity

  1. dsyme commented on Jan 10, 2020

    @dsyme
    Contributor

    Yes, this should be added.

  2. eiriktsarpalis commented on Jan 13, 2020

    @eiriktsarpalis
    MemberAuthor

    I'm looking at the corresponding code in FSharp.Reflection, and it looks like the public API requires passing the Assembly instance containing the System.ValueTuple declarations. I'm assuming this was done to address pre-netcoreapp2.0 runtimes? And if so, is there still a need to reflect a similar api shape in Expr.NewStructTuple : Assembly * Expr list -> Expr?

  3. added
    Area-Library
    and removed on Jan 14, 2020
  4. eiriktsarpalis commented on Nov 5, 2020

    @eiriktsarpalis
    MemberAuthor

    Closing since this has already been implemented.

  5. modified the milestones: Backlog, 16.5 on Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-LibraryFeature Request

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions