Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upOpt into y-down semantics by implementing a trait on the unit #361
Conversation
|
@kvark @Manishearth @SimonSapin @asajeffrey Which do you prefer between this approach and the one in #353 (or some other alternative)? |
|
I like this much more than #353 , I almost very much like this :) |
|
Indeed I should have mentioned this other possibility in my initial comment. I am not against making euclid completely agnostic (removing all y-down specific names), but since it can be a pretty important change for code that relies a lot on these conventions (I suspect servo layout would be more impacted than webrender for example), I want to make the sure interested parties are OK with something like that. What would the declaration of SideOffsets2D be like in a world where top, left, etc. can't be used? |
|
Eh, I like this approach in principle, but I just spent way too much time dealing with a typed API that I needed to mold into the kinds of types that would work -- because a lot of what was compile time in the API was runtime for me. Typed units are nice, but this forces people to use them and I don't think they work out in all situations. UnknownUnit needs to implement the trait, but if we do that then you lose the opt in. |
If UnknownUnit needs to implement the trait, then I am not enthused by this approach because:
So in that case I'd rather make it a feature flag. This indeed forces people who do want y-down semantics to use units, is your concern related to servo code or is it in general? Since servo crates use units in a lot of places I expected this wouldn't be an issue there. What is your take on getting rid of all y-down specific methods as @kvark proposed? |
General, not a servo thing. Typed units are great but you are often forced to cast to work around them when they don't quite match up to what you need, and it can get ugly. Feature flag would be totally fine. I don't have an opinion on getting rid of them, I haven't dealt with the servo code using it as much. |
|
|
nical commentedJul 10, 2019
•
edited by larsbergstrom
Alternative to #353.
Instead of using a global feature flag, only implement methods with names that depend on the meaning of the y-axis orientation if the unit implements the YDown trait.
The main difference is that the choice is made on a per-unit basis instead of a per-dependency basis.
The upsides are:
On the other hand:
YDownprevent all other users of these types from having y-down semantics, which is not great (but not the end of the world either).Either way there is no intent to add y-up specific methods.
This change is