You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, preferunits works by changing the values in the global dictionary Unitful.promotion. This causes problems with precompilation (#545, #600).
My suggestion for Unitful v2.0 is to replace the global "unit preference dictionary" (Unitful.promotion) by an object that the user creates and explicitly uses to convert to their preferred units. Instead of
preferunits(cm)
upreferred(1m)
the user would do the following:
my_unit_preference =UnitPreference(cm) # this returns a UnitPreference object, does not alter global statemy_unit_preference(1m) # the UnitPreference object is callable
However, this means that automatic promotion would not promote to the user’s preferred units but always to the default units (unless they are using ContextUnits/FixedUnits).
Introducing this new UnitPreference object can be done in a minor release, but removing the possibility of setting a global unit preference would be breaking.
The text was updated successfully, but these errors were encountered:
My initial feeling says that this is the more sane of the two solutions discussed for #545. Howeverthis seems to shift the temptation to create global state to client packages...
Currently,
preferunits
works by changing the values in the global dictionaryUnitful.promotion
. This causes problems with precompilation (#545, #600).My suggestion for Unitful v2.0 is to replace the global "unit preference dictionary" (
Unitful.promotion
) by an object that the user creates and explicitly uses to convert to their preferred units. Instead ofthe user would do the following:
However, this means that automatic promotion would not promote to the user’s preferred units but always to the default units (unless they are using
ContextUnits
/FixedUnits
).Introducing this new
UnitPreference
object can be done in a minor release, but removing the possibility of setting a global unit preference would be breaking.The text was updated successfully, but these errors were encountered: