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
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
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
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.
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.
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.
Activity
1ec5 commentedon Mar 27, 2018
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
literalexpression, 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.1ec5 commentedon May 8, 2018
There’s two parts to this task:
+[NSExpression(MGLAdditions) expressionWithMGLJSONObject:]needs to expand out any occurrences of this one-to-many shortcut in amatchexpression:mapbox-gl-native/platform/darwin/src/NSExpression+MGLAdditions.mm
Lines 934 to 938 in ea59ba8
MGL_MATCHsyntax 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.1ec5 commentedon May 8, 2018
This isn’t necessary if
MGL_MATCHsupports using an aggregate expression as an input value, which is the approach taken by #11866.