Re: [css-variables] CSS Variables are a NEW kind of variable

From: Divya Manian
> Sent: Wednesday, May 30, 2012 2:58 AM
> To: www-style@w3.org
> Subject: Re: [css-variables] CSS Variables are a NEW kind of variable
>
> Here is what I find weird as a dev about the new syntax:
>
> 1. Var is a variable "property" yet it is invoked as a function. I assert
> then it is not a property and we should not treat it as such. Everything
> about a variable does not sound like a property to me. A Variable seems to
> be a name/value pair of a defined type called Variable. I think it is very
> wrong to shoe-horn this new kind of syntax into an existing 'property' and
> try to reuse the same definition by attaching more prefixes.

This is where our point of view diverges, actually.

For instance, if I was responsible of the spec, I think I would have renamed 
"variables" into "user-defined properties".



> 2. I do think the cascading would make it easier for authors to work with
> variables as it provides a scope for vars. This is awesome.

Glad you're liking it. If all the threads about CSS variables are showing 
anything, this is at least that it's necessary to better communicate about 
CSS variables, explain to authors why they are useful, and give them 
concrete samples, or I'm sure they'll never spot the difference between 
BASH/SASS/CSS implementations.



> 3. Variables - as defined in spec - take only one argument when they are
> invoked as a function, this begs the question of why they are functions to
> begin with? This is completely contrary to how I have seen functions being
> used. First functions are represented in easier ways by their actionable
> names rather than just generic ones like 'var'. I can even understand
> 'calc' but 'var' is just puzzling.

I completely agree. I also would prefer something like "just use an 
identifier".

    :root { x-link-color: blue }
    a { color: x-link-color }

If this is not possible to do, we shall need an introductory token, which $ 
can be. However, even with "x-", the var() function should be kept to 
provide a default (as second argument) for when the variable is invalid.



Anyway, if you want my opinion, I think the $foo syntax is the syntax that 
will probably be used, for practical reasons. But, at least, if will not be 
a purely esthetical choice from the spec editor AND it will have driven 
reflection about how the WG should communicate upfront about CSS variables. 
I already have 'won' if the WG communicate better about variables.

There's just one thing I don't understand about the $foo choice: why the 
hell does it use a preprocessor-like syntax knowing that it will not (and 
should not) replace preprocessor variables. 

Received on Wednesday, 30 May 2012 08:00:30 UTC