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

Bend NSExpression syntax to accomodate Studio expression syntax #11053

Closed
1ec5 opened this issue Jan 25, 2018 · 4 comments
Closed

Bend NSExpression syntax to accomodate Studio expression syntax #11053

1ec5 opened this issue Jan 25, 2018 · 4 comments
Labels
iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS runtime styling

Comments

@1ec5
Copy link
Contributor

1ec5 commented Jan 25, 2018

The NSExpression-based property value implementation in #10726 relies in large part on an existing NSExpression format string syntax. Studio is planning to use its own abstraction atop the style specification’s expression language, powered by expression-jamsession. Both syntaxes are more or less inspired by spreadsheet formula syntax, but there are some subtle differences. We should explore having -[NSExpression(MGLAdditions) mgl_jsonExpressionObject] interpret the format string more loosely to accommodate differences that may easily lead to confusion. For example:

  • min() and max() take a single array literal argument in NSExpression but a series of arguments in expression-jamsession.
  • Accessing a feature’s attribute entails a key path expression in NSExpression but a call to get() in expression-jamsession.
  • Concatenating strings currently requires a call to stringByAppendingString: (but soon mgl_join()) in NSExpression but the & operator in expression-jamsession. Per Reimplement MGLStyleValue atop NSExpression #8074 (comment), we can overload the bitwiseAnd:with: function for this purpose.

/cc @davidtheclark @anandthakker @jmkiley

@1ec5 1ec5 added iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS runtime styling labels Jan 25, 2018
@1ec5 1ec5 added this to the ios-v4.0.0 milestone Jan 25, 2018
@1ec5
Copy link
Contributor Author

1ec5 commented Jan 25, 2018

Placing this issue on the v4.0.0 milestone to investigate, without necessarily committing to implementing this feature.

@1ec5
Copy link
Contributor Author

1ec5 commented Jan 26, 2018

Also, for forwards compatibility, we can add a freeform custom function that takes a style specification–flavored expression array, to be used whenever we encounter an operator that doesn’t readily translate to NSExpression syntax.

@1ec5 1ec5 modified the milestones: ios-v4.0.0, ios-v4.0.1 Apr 18, 2018
@1ec5 1ec5 removed this from the ios-v4.0.1 milestone May 8, 2018
@1ec5
Copy link
Contributor Author

1ec5 commented May 8, 2018

We ended up shipping v4.0.0 without these compatibility shims. We won’t be able to add them for v4.0.1, but we remain open to adding them in the future based on developer feedback.

Also, for forwards compatibility, we can add a freeform custom function that takes a style specification–flavored expression array, to be used whenever we encounter an operator that doesn’t readily translate to NSExpression syntax.

#11472 added an MGL_FUNCTION() function (from the department of redundancy department) that can represent any style specification–flavored array.

@1ec5
Copy link
Contributor Author

1ec5 commented Jun 21, 2018

We aren’t adding these compatibility shims in the near future, but we’re open to reconsidering in the future based on developer feedback.

@1ec5 1ec5 closed this as completed Jun 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS runtime styling
Projects
None yet
Development

No branches or pull requests

1 participant