Re: [css-variables] Why we can not use 'var()' function for normal property

02.06.2015, 19:45, "Tab Atkins Jr." <jackalmage@gmail.com>:
> On Tue, Jun 2, 2015 at 9:27 AM, Marat Tanalin <mtanalin@yandex.ru> wrote:
>> Instead of fearing cycles at all, we could just limit nesting/recursion
>> level for `var()`, so that once some reasonable limit (e.g. 10)
>> is achieved, applying styles referenced by corresponding nested `var()`
>> calls is just stopped.
>
> there's no "recursion". šCSS is declarative, not imperative; there's no defined evaluation order.

On implementation level, _there is_ an evaluation order anyway. Exact order is not necessarily should (or even must not) be described in a spec, it should be enough just to spec a specific limit. For example, the spec could say:

"If there are more than 10 nested `var()` calls,
 then all involved properties must be ignored."

For example, if we had a specced/implemented nesting limit of 3 (exact number of 3 would probably too small in practice and is used just for code-example brevity), then with this CSS code:

    a: var(b);  /* #1 */
    b: var(c);  /* #2 */
    c: var(d);  /* #3 */
    d: var(e);  /* #4 */

an implementation would stop the "recursion" on `var(e)` since it is 4th `var()` in the `var()` chain. In another implementation, evaluation order could be different, but the result should be the same -- once nesting-level limit is reached, reading the chain is stopped and all properties in the chain are ignored.

Received on Tuesday, 2 June 2015 17:37:43 UTC