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
MI use subtypes of SingleValue (itself a dataclass) to provide distinct types for a range of quantities, in order to allow type checking for some function calls. These are wrappers around a base type. For example a Degree holds a float, but the type checker can prevent a Slope (also holding a float), being passed to a method that takes a Degree. There is also some code for runtime type checking in the SingleValue constructor, but this does not run for subtypes. Degrees("Hello") does not raise a error at runtime.
Desired Behaviour
Since python 3.5 the typing model has offered NewType, this has most of the static benefits with lower runtime overhead. We'd loose the ability to add constructors to do runtime checking, but we were not using this. And we loose the ability override operators, but we were not enforcing anything with this.
We would no longer need to use a.value to unpack the value, because at runtime there is no wrapping.
The text was updated successfully, but these errors were encountered:
Current Behaviour
MI use subtypes of
SingleValue
(itself adataclass
) to provide distinct types for a range of quantities, in order to allow type checking for some function calls. These are wrappers around a base type. For example aDegree
holds afloat
, but the type checker can prevent aSlope
(also holding afloat
), being passed to a method that takes aDegree
. There is also some code for runtime type checking in theSingleValue
constructor, but this does not run for subtypes.Degrees("Hello")
does not raise a error at runtime.Desired Behaviour
Since python 3.5 the typing model has offered
NewType
, this has most of the static benefits with lower runtime overhead. We'd loose the ability to add constructors to do runtime checking, but we were not using this. And we loose the ability override operators, but we were not enforcing anything with this.We would no longer need to use
a.value
to unpack the value, because at runtime there is no wrapping.The text was updated successfully, but these errors were encountered: