Re: [css-variables] var() for non-custom properties

On Fri, May 22, 2015 at 7:58 PM, Glen Huang <curvedmark@gmail.com> wrote:
>> Yes, this is the main reason we don't and won't allow this.
>
> IMHO, this is like saying since recursions have the possibility to loop forever, they shouldn't exist.

There is a huge difference between an infinite loop in a normal
programming language, like JS, and a cycle in a declarative
programming language, like CSS.  The former just has annoying
behavior; the latter is *undefined*.

> I think the benefit of being able to reuse computed values far outweighs the hiccups created by cyclic dependencies (just look what all kinds of crazy stuff js can do if it's used for layout).
>
> If cyclic dependencies do raise up, I think we can simply discard the culprit properties and treat them like they never exist, like how we resolve `--foo: var(--foo); color: var(--foo)` if I'm not wrong.

Cycle checkers are expensive, and so we want to minimize their use.
Currently we limit the checking to just custom properties, which
limits their cost.

> I discovered gss[1] recently. They took this property dependencies to the next level with VFL[2]. I wonder if there is any interest in evolve css to that direction?
>
> [1] http://gridstylesheets.org/
> [2] http://gridstylesheets.org/guides/vfl/

That's something quite entirely different - constraint programming for
expressing relationships between properties on multiple elements.  CSS
*itself* will not move in that direction, but one of the explicit
goals of the Custom Layout part of CSS's Houdini taskforce is to be
able to accommodate things like GSS properly.  In a few years you
won't have to do any preprocessing to use GSS, just include a small JS
library!

~TJ

Received on Saturday, 23 May 2015 18:36:46 UTC