Unit Access Ramifications e.g. Materialization #51
Replies: 3 comments
|
I don't know exactly the fuel internals, but on a quick search, looks like |
|
I considered such an approach, but wasn't sure how to go about it since:
|
|
The other wrinkle is that Aconcagua's stores of units (e.g. InternationalSystemOfUnits) are not fixed. If the user simply takes responsibility for serialization of the class-side variables, any units added to Aconcagua after that initial save will not be added. This pushes me further down the road considering including state in the unit objects to recreate the unit - something like |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
In v11, there are two properties of units that seemingly make them hard to work with:
InternationalSystemOfUnits units >> #litreandUSCustomaryUnits units >> #poundDerivedUnitandUnitOfAccountI'm not clear how this can work in practice. For example, say I serialize data including Quantity instances, like recipes with ingredient amounts like 2 tsp. How can this data get materialized? If the data is saved naively, the materialized unit of the quantity will not be the one in the class-side collection, but a copy. Since unit equality is identity-based (i.e. not overridden from the built-in Object implementation), the system will now report false for
2 tsp unit(materialized) ==2 tsp unit(newly created). I suppose a user might decide to take over the responsibility to serialize and materialize and used Aconcagua unit collections, but that seems like an odd requirement for a simple use case.All reactions