-
Notifications
You must be signed in to change notification settings - Fork 3.4k
How to handle mixed unit math #3047
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
Comments
Honestly, I've never been a fan of being able to mix units in Less. It makes no sense from a mathematical perspective, and as you point out, it's all based on the evaluation order.... which also makes no sense. However, when I looked at the So, yeah, that's weird, but I'm not inclined to see it fixed. I'm more inclined to see mixed-unit math go away. But that's just me. Like the result of
The math here is Just my $0.02. |
I think what should happen is that, like the changes to math, there's a change in mixed units so that there's a third option between the two:
|
The issue is not about personal opinions of units/arithm handling. It's about compiler not following its own documentation. (For the rest see for example #1366 (comment)). |
Yeah, I get that. But ultimately it's about how to "fix" it, right? So I'm just saying in a roundabout way that I don't think this is worth the time to fix, and instead it should have a more intuitive behavior. But yeah, that's just, like, my opinion, man. |
@seven-phases-max Just a note: I've re-written most of the operate methods for units, and they indeed had some weird acrobatics for determining the final unit. I've gotten it to be much more straightforward where the left-hand-side unit wins when coercing units is the option passed in. |
(There were a few threads where a different opinions on possible strict units improvements but since that was spread all over the tracker (or at least I can't find a dedicated thread quickly) I guess I simply sound the key part of:)
is something like: would not be worth it (because of outcome/efforts ratio). In other words it's nothing to improve actually (except just fixing the obvious bugs like above). Notice that to have it truly generic (in oppose to harcoding these and that minimalistic values/ops patterns/examples) you'll need to properly handle all the usual arithmetic equalities and thus introduce "imaginary" units like There're other implementation concerns (obviously it would look strange to also count things like
Basically if one does not like the unit propagation and/or mixed units thing he may introduce a stricter coding style not allowing such arithmetic (thus current |
c
andd
results above contradict with http://lesscss.org/features/#features-overview-feature-operations stating the result should have a leftmost unit of an expression (i.e. all expressions above should produce1px
). Tests cover onlya / b / c
expression which accidentally produces the expected result.Related to #2418 and #2472.
The text was updated successfully, but these errors were encountered: