Makes quantities occupy a different namespace from units. This means you can no longer write them in expressions as though they were units, which was confusing.
Fixes#12, which is one of the longest standing bugs in Rink.
Yet another giant refactor PR. I'm trying to clean up the Context internals. I moved a lot of the fields into a new Registry object with the hopes of making future refactors to it easier.
A lot of things are poorly named, and I've been going through and updating those. Some of these fields I didn't even know what they did until I studied them carefully, since I'd forgotten over time.
This makes some breaking changes to the Defs serialization format, but I didn't touch Unit or Substance which are the only ones that are used by the backend currently.
Some other refactors I did:
- Updated quantities to no longer reference units, only base units and other quantities.
- Added a debug dump option to the CLI for showing the contents of the Context.
- Merged Def::BaseUnit & Canonicalization.
- Merged Def::Prefix & SPrefix. I don't actually know what SPrefix stood for originally (standalone? definitely not short).
- Prefixes are now required to be dimensionless.
- Added missing tests for the Def serialization format.
I'm not entirely done yet though. There's still one dependency on Context from the loader, which is on the eval() method, used by units and substances. I'm still thinking about how I can reduce that coupling.
Much of the code organization and architecture of Rink has been the same since I hacked this project together in 2016. In this PR, I spent about a day moving files around and refactoring code.
I'm hoping that cleaning up the codebase like this will help make it easier to change going forwards. There's a lot of duplicated code, few abstractions are used.
In order to make this not break everything I did it in tiny steps, verifying the test suite each time. The original branch has >30 commits in it as a result.
Most users probably want to manipulate time relative to the present in
their local timezone. This brings rink's functionality closer to similar
tools.
In date(1):
> date -d 'now + 1 hour'
Fri 23 Jul 09:54:02 CEST 2021
Before:
> now
2021-07-23 06:54:05.699222874 +00:00 (now)
> now + 1 hour
2021-07-23 07:54:10.940110380 +00:00 (in an hour)
After:
> now
2021-07-23 08:54:13.219044877 +02:00 (now)
> now + 1 hour
2021-07-23 09:54:15.555096329 +02:00 (in an hour)