-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add coercing versions of conversion functions
These are variants of `.as` and `.in` for both `Quantity` and `QuantityPoint`. When we precede these with the "coerce" vocabulary word, they become forcing, ignoring the safety checks for truncation and overflow. This new syntax has two major advantages over the explicit-Rep version. First, it makes the intent clearer. Second, it stops forcing users to repeat the rep when they want the same rep they started with, which I think is the usual case. (Thus, without these APIs, explicit-rep obscures intent: one never knows whether the author wanted a cast, or wanted to bypass the safety checks.) It also unlocks another, later improvement: we will be able to extend the safety checks to the explicit-rep versions! But we won't attempt that for a while because that's a breaking change. There may be other APIs that would benefit from using the "coerce" vocabulary word instead of explicit-rep. However, we'll start with just these, both because they're the overwhelmingly most common use case, and because it gives us a chance to try out these ideas in practice for a while. Helps #122. We'll start with just these functions because they're by far the most prevalent. Later on, we can
- Loading branch information
Showing
10 changed files
with
266 additions
and
51 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
Oops, something went wrong.