Subject: Re: bug#15859: 24.3.50; Calc - dimensionless units again

From: Roland Winkler <[email-masked]>
Date: Mon, 17 Apr 2023 10:20:15 -0500

On Mon, Apr 17 2023, Michael Heerdegen wrote:
> I would like to know what the changes since then tried to accomplish/fix
> and what we loose when we revert to the old definition.

That's a very good question.  In my experience, there was never a
problem with the old code where it yielded incorrect results nor have I
encountered a situation where these changes improved anything (in
whatever vague sense).

Most importantly, at some point I checked the bug-gnu-emacs archive,
when I could not find a bug report that could have triggered the changes
in the code, nor there was any explanation in a ChangeLog or commit
message that would have explained why these changes were done.

So from all I can tell, these changes were introduced for no clear
reason, but they only broke things.

>> (defun calc-convert-units (&optional old-units new-units)
>>   (interactive)
>> [...]
>
> Reverting only that definition does not fix your
> "convert 7m / (c s) to in / (c hr)" example.

Good point.  I must have come up with this example at a point in time
when I couldn't check what the old code would do.  In any case, running
this example with the old code yields a behavior that is mathematically
perfectly correct, whereas the new code asks a meaningless question
about a unit for the expression "7m / (c s)".  Strange enough, the old
code even handles fine the case that "7m / (c s)" is converted to a
user-defined dimensionless unit such as Pi.

Again, the bottom line is that the old code works correct, whereas the
new code cannot handle expressions where the units can be simplified to
a dimensionless number.  Therefore, I believe reverting the changes to
calc-convert-units is the best thing to do.  Then, any future changes
should document the use cases they intend to fix or address.