-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Order of operation when creating constraint #71
Comments
Pattern matching could be used to prevent orders that aren't supported or the math could be inversed within the Anchorage operator to achieve the desired effect using auto layout's native evaluation order. |
This stems from the fact that the operators are an interface into building a
In the sample that @BrianSemiglia posted, the original expression looked like this:
The user of this code would probably expect that the multiplier would distribute across the expression, resulting in this:
However, order of operations is not honored. No matter the order, the constant and multiplier are both just set on the expression directly. What should we do about it?We could fix this by introducing more intermediate types to capture the order of operations, but that would be a breaking change: anyone who currently has some code that uses the current behavior is technically using it wrong, but if their code is working for them, correcting the multiplicative distribution would change their layout. Instead, I think it might be a good idea to build those intermediate types to capture the order of operations, but then use availability/deprecation annotations to show the user a warning that they are using Anchorage incorrectly (i.e. "holding it wrong"). In my opinion, an Anchorage expression should look like the underlying expression it represents, which always takes the form |
I agree with @ZevEisenberg that the expression format should be enforced. I don't think there's a strong use case for the distributive property when building layout constraints, except in contrived examples. Perhaps adding a deprecation/warning to the
|
We could be strict about the ordering as well: Good call on the overrides. We may not need any new intermediate types; just stricter annotations on existing ones. Edit: math is hard |
To clarify: I think it makes sense to accept any expressions that are unambiguously, algebraically equivalent to |
The text was updated successfully, but these errors were encountered: