Rightpoint / Anchorage

A collection of operators and utilities that simplify iOS layout code.
MIT License
632 stars 46 forks source link

Use custom operators #26

Closed phatmann closed 7 years ago

phatmann commented 7 years ago

I love the idea of stating a constraint as an equation. However, using the bare equality and comparison operators for this purpose seems semantically incorrect and is bound to make the code harder to understand than it should be. I would suggest that we surround the equality and comparison operators with vertical bars to indicate "constraint". For example:

   view.topAnchor |>=| container.topAnchor + 5

This also lets us change the operator precedence if we need to.

In order to preserve backward compatibility, we could make the adorned operators the default, but allow bare operators via conditional compilation.

If you are interested in this, I could put a PR together.

jvisenti commented 7 years ago

Thanks for the feedback, but at this time we are going to stick with the ==, <= and >= operators because they are familiar to most users, and show clear intent especially with regards to the inequalities.