-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate bare-offset-unit maker names (#35)
If a unit has a nonzero offset, then that implies it will typically be used as a _point_, rather than a _quantity_. So far, our convention has been that quantity makers get the name of the unit, and quantity _point_ makers get that name with a `_pt` suffix. However, this turns out to be really error prone for offset units: the default name will give users something that behaves in surprising ways. As a more concrete example, `celsius(0)` is equal to `fahrenheit(0)` currently. Since these are quantities, this makes sense! But to the reader, these just "look like temperatures" (which are _points_), so the appearance is misleading and will lead to mistakes. We _could_ say that the "bare unit name" for _offset_ units belongs to the quantity _point_ maker. But then it becomes harder to reason about what "kind of thing" a bare-named maker will return. It also creates an unfortunate inconsistency between `celsius` and `kelvins`, say. I think the better answer is to recognize that a name like `celsius` is _intrinsically_ ambiguous. Since it's the one users will reach for, we can keep it in the library, but purely for the purpose of giving a readable deprecation warning. We will tell users to say `celsius_pt` if that's what they mean, and `celsius_qty` (using a new `_qty` suffix convention) otherwise. Fixes #34.
- Loading branch information
Showing
7 changed files
with
19 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters