Re: WebKit now supports CSS Variables

On Jun 30, 2008, at 12:26 PM, Francois Remy wrote:

>
>>> In any language, if you try to write something like "const x = 1"  
>>> in file1 and
>>> "const x = 2" in file2 (assuming that both file a defining the  
>>> variable on the
>>> same scope), you will get a compilation error and nothing of your  
>>> code will
>>> be compiled.
>>
>> Depends on many factors, cases and languages. In most languages you  
>> can define constants with the same name but e.g. in different  
>> namespaces and probably files.
>
> If you are "assuming that both file a defining the variable on the  
> same scope",
> then it's not possible.
>
>> CSS uses "silent recovery" method of parsing. So if you have
>> two entities with the same name you have only two options in CSS:
>>
>> 1) first seen - first used. That is @const.
>> 2) last seen - last used. That is @var.
>
> Yes, but what's "first" seen ?

The concept of first last and source order are already well  
established for CSS, as it is used for latter rules to override  
earlier ones. So what is hard to understand about "first" seen?


> 1. The first style that's sucessfully parsed ?
>> Then it's not possible for the developers to be sure which @const  
>> wil be used.

Why not? Its not that different from picking the @var to use, based on  
which one is seen last.

>>
>
> 2. The first sytle in the DOM ?
>> Then, it can change during the application. So you can't use that  
>> for a variable.
>
> But you'll see it yourself, when you will need to make a true W3C  
> Spec, defining exactly
> all process that define how you compute a value of a constant.
>
> Fremy
>
> PS : Last seen is easy. It's the last in the document DOM. It can  
> change and it's not a problem
> if we decide to use variables. And it's the only way CSS have been  
> parsed at any time. I see
> no spec that say "first seen is first used".

It will if we go with something like constants instead of variables.

> Because it's not possible to have "a first seen" that
> you can assume as immutable for all the time the page will be running.

The important thing is that you can assume it is immutable during the  
loading of the CSS. As I see it, how you should handle changing it via  
JavaScript is a separate issue.

> Keywords are so.
> But keywords are true constant... because it's not possible to  
> override and disable them.

One of the ideas for @const is that you could override keywords too  
(presumably once per page).

Received on Monday, 30 June 2008 19:59:09 UTC