Subject: Re: bug#10554: 24.0.92; No units specified (dimensionless quantities in Emacs Calc)

From: "Roland Winkler" <[email-masked]>
Date: Fri, 20 Jan 2012 16:10:44 -0600

On Fri Jan 20 2012 Jay Belanger wrote:
> > I would, indeed, consider it quite OK if an error was signaled. Say,
> > if there was an option calc-throw-error-if-units-mismatch, I'd bind
> > it to t.
> 
> Having such an option shouldn't be too hard to take care of, after 24.1
> comes out.  By default, though, the current behavior shouldn't change,
> and so the option should have default value nil.

Great, thanks! Do you also see a possiblity to implement the other
scheme I suggested (attached below once more)? That would be
wonderful!

Roland

I guess we can have the following scenarios that can be handled as
follows:

(1) If the old expression and the new unit have the same dimension,
    "1" should be treated like any other unit.

    So this means: 

    - if the old expression has units that cancel completely (e.g.,
      as in my orginal bug report) or it has a unit like "alpha",
      one can specify "1" as the new unit and the unit conversion
      returns a plain number.

    - similarly: if the old expression is just a number (i.e., unit
      "1"), this can be converted to other dimensionless units such
      as "alpha" without being asked for the old unit.

      (Yes, I am irritated if calc-convert-units asks me about the
      old unit if there is just a plain number on the stack. So
      backward compatibility would probably require a variable such
      as calc-treat-numbers-as-dimensional, bound to nil by
      default.)

(2) The old expression is not dimensionless such as "7 m", the new
    unit is "1". Here I suggest that partial conversion means to
    return the old expression without any unit conversion.

    (this would be quite consistent with how Calc already treats the
    case that the old expression is something like "7 m", and the
    new unit is "alpha".)

(3) The old expression is a dimensionless number, the requested new
    unit is something like "m":

    Here I suggest to just return the old expression unmodified

    (again, this would be quite consistent with how Calc already
    treats the case that the old expression is something like
    "7 alpha", where conversion to any other unit gives a
    dimensionless number.

Did I miss another possibility? If yes, I am sure that it has a
reasonable solution, too.