Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Match expression should allow associating an array of inputs to an output #11539

Closed

Description

@1ec5

The mgl_match: expression function added in #11464 should ideally allow an aggregate expression to be used in place of a single input argument. This would cut down on repetition when converting the IN predicate operator to style JSON and make it possible to round-trip the IN operator more directly.

/cc @fabian-guerra @anandthakker

Activity

  1. added
    GL JS parity
    iOS
    macOS
    on Mar 27, 2018
  2. 1ec5 commented on Mar 27, 2018

    @1ec5
    ContributorAuthor

    Allowing an input argument to be an aggregate expression could be tricky, because our NSExpression implementation doesn’t distinguish between arrays used as values and arrays used for control flow. Whereas the style JSON language wraps arrays-as-values in a literal expression, our NSExpression implementation currently appears to interpret an aggregate expression or NSArray as a value or not based on context.

    I wonder if we could get away with always translating NSArray objects as literals while treating aggregate expressions as something more structural. That would complicate trivial use cases, such as in our examples, but possibly avoid some thorny corner cases.

  3. added this to the ios-v4.0.1 milestone on Apr 24, 2018
  4. self-assigned this
    on May 2, 2018
  5. 1ec5 commented on May 8, 2018

    @1ec5
    ContributorAuthor

    There’s two parts to this task:

    • +[NSExpression(MGLAdditions) expressionWithMGLJSONObject:] needs to expand out any occurrences of this one-to-many shortcut in a match expression:
      while (id object = optionsEnumerator.nextObject) {
      NSExpression *option = [NSExpression expressionWithMGLJSONObject:object];
      [optionsArray addObject:option];
      }
      This would be a quick fix, I think.
    • We need an MGL_MATCH syntax for associating multiple input values with a single output value. Or maybe we don’t need this at all. This would be more difficult, because we currently treat aggregate expressions and NSArray-typed constant values the same way.
  6. 1ec5 commented on May 8, 2018

    @1ec5
    ContributorAuthor

    +[NSExpression(MGLAdditions) expressionWithMGLJSONObject:] needs to expand out any occurrences of this one-to-many shortcut in a match expression

    This isn’t necessary if MGL_MATCH supports using an aggregate expression as an input value, which is the approach taken by #11866.

  7. modified the milestones: ios-v4.0.1, ios-v4.0.2, on May 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GL JS parityiOSmacOSruntime styling

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions