- From: Tab Atkins Jr. via GitHub <sysbot+gh@w3.org>
- Date: Wed, 03 Aug 2022 18:06:49 +0000
- To: public-css-archive@w3.org
Restating the proposal from above, to make it easier to reference for the discussion: ``` random( [ [seed <custom-ident>]? && per-element?]! , <calc-sum>, <calc-sum>, [by <calc-sum>]? ); random-item( [ [seed <custom-ident>]? && per-element?]! , <single-value># ); ``` random() requires all its calc-sum arguments to add to the same type. It canonicalizes its arguments, and when they're fully resolved, gives a random numeric value of the appropriate type that is between the low and high values. If a precision is provided, it selects a value randomly from all values of the form (low + N * precision) that are less than or equal to the high value. (Insert corner-cases about low vs high ordering, and precision sign.) This is a [math function](https://drafts.csswg.org/css-values/#math-function), with all that implies. (In particular, it means we don't need to separate out random integers from reals; saying random(foo, 1, 10, by 1) will provide integers, and using random() in a place that expects integers will trigger rounding if necessary.) random-item() evaluates to one of its arguments. They can be of any type. <single-value> is a not-yet-defined production similar to <any-value> that doesn't allow top-level commas. Because we can't tell what the type of the value is, random-list() triggers the same behavior as a var() - property is assumed valid at parse time, and becomes IACVT if substitution ends up giving a bad result. random() caches its results by a tuple of (custom-ident, low, high, precision, element-specific identifier if per-element, document-specific identifier). random-item() just caches by (custom-ident, element-specific identifier if per-element, document-specific identifier). This means you'll get identical results every time the same function is used, anywhere in any stylesheet, on a single page load. (If per-element is specified you'll get different results per element, but the same results on a particular element every time.) -- GitHub Notification of comment by tabatkins Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2826#issuecomment-1204305712 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Wednesday, 3 August 2022 18:06:51 UTC