This shows you the differences between two versions of the page.
Last revisionBoth sides next revision | |||
spec:limited-ranges [2012/11/20 12:49] – created tabatkins | spec:limited-ranges [2013/10/15 11:33] – specify closed ranges tabatkins | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Always Use Closed Ranges ====== | ||
+ | |||
+ | When designing a property with a limited range, **always** use a closed range; that is, a range with definite endpoints (or infinity). | ||
+ | |||
+ | This is because open ranges make it impossible to predict whether a given value close to the boundary will end up inside or outside the range, as it depends on UA-specific precision and rounding behavior. | ||
+ | |||
+ | Some values are most naturally expressed as an open range - for example, when expressing a length which will be repeated to fill another length, the first length obviously must be greater than zero to avoid a division error. | ||
+ | |||
+ | - Define that there is a minimum value (possibly UA-specific), | ||
+ | - If the behavior is convergent as the value approaches the boundary, define the behavior at the boundary to be the limit behavior. | ||
+ | - As a final option which should be avoided if possible, define a different behavior entirely for the boundary. | ||
+ | |||
+ | ====== Make it Invalid Outside the Range ====== | ||
+ | |||
The Values & Units spec already defines that, when a property restricts a value to a particular range, setting a value outside of that range is a syntax error and must cause the property to be ignored. ([[http:// | The Values & Units spec already defines that, when a property restricts a value to a particular range, setting a value outside of that range is a syntax error and must cause the property to be ignored. ([[http:// | ||
Line 12: | Line 26: | ||
In other cases, it's hard (or impossible!) or expensive to respect the author' | In other cases, it's hard (or impossible!) or expensive to respect the author' | ||
+ |