W3C home > Mailing lists > Public > www-style@w3.org > July 2008

Re: Proposal for adding variable declaration blocks

From: Francois Remy <fremycompany_pub@yahoo.fr>
Date: Fri, 18 Jul 2008 22:14:33 +0200
Message-ID: <E03EC0A247AA4BFC8791B7115BFAA057@FremyCompany1>
To: "Simetrical" <simetrical@gmail.com>, "James Elmore" <James.Elmore@cox.net>
Cc: "www-style list" <www-style@w3.org>

I don't like $varName. I much prefer var(varName);
At the beginning I was for @varname but now, I've changed my stand of view.

Here are two reasons I can find :

    1. Extensibility of the model

If we choose for var(varName), it will be possible later to add some other 
functions like :

    var(oHeight + '5px')
or
    var(oWidth * 3)
or
    var('10%' - ('50px' * 2))
or
    color: var(iif(isDefined('tColor'), tColor, 'blue'))
or
    ...

In this case, "var" will be a "variable expression" which can accept "css 
variables".
Currently, "var" is only sending a pointer to a "css variable", but it can 
change in the future.

BTW, a variable expression will not break the evalution of the variables 
because variables are currently resolved after the CSSOM.
And variables expressions should be resolved after too, so there's no 
problem at all.

    2. CSS is not PHP

$ is only used in PHP but CSS is not a PHP extension.
Now, there's Java, ASP (JScript/VBScript) and ASP.NET (VB.NET, C#, J#, ...) 
that are very difused web languages.
Why should CSS choose for a PHP-like syntax more than a C# syntax ?

var() is clearly new and allow to avoid conficts while $ can be used later 
in CSS Specifications.

Fremy

PS : I'm not against $varName as shortcut of var(varName);

--------------------------------------------------
From: "Simetrical" <simetrical@gmail.com>
Sent: Friday, July 18, 2008 8:52 PM
To: "James Elmore" <James.Elmore@cox.net>
Cc: "www-style list" <www-style@w3.org>
Subject: Re: Proposal for adding variable declaration blocks

>
> On Fri, Jul 18, 2008 at 2:41 PM, James Elmore <James.Elmore@cox.net> 
> wrote:
>> By the way, (possibly I missed this) is there a suggestion about using 
>> the
>> variable sigil (interesting word -- I would use indicator) for the 
>> variable
>
> I got it from Wikipedia, and I think it's an amusing term, so I'll go with 
> it.
>
> http://en.wikipedia.org/wiki/Sigil_(computer_programming)
>
>> Would it make CSS parsing easier if every use of the variable (LHS and 
>> RHS;
>> setting and getting) required a sigil? Or would that make things more
>> complex, because then idiots could do things like:
>>
>> <style>
>>    declare { $color: #00ff00; }
>>    h1 { color: $color; }
>> </style>
>
> If some kind of sigil is used, there's no reason to prevent keywords
> from being used in variable names.  The sigil will effectively
> distinguish variables from keywords.  For comparison, other
> implementations I'm aware of (PHP and bash, mainly) reserve no
> variable names -- $function, $while, and so on are perfectly valid.
> (Both do predefine certain variables before the program begins
> executing, but those variables can generally be changed like any
> other.)
>
> With the huge number of keywords CSS uses, it seems like a good idea
> to avoid conflicts, as I remarked previously.  In some contexts,
> $color would be a very reasonable choice for a variable name.  I don't
> think you'd have to be an idiot at all.
>
> As for whether to use the sigil in the declarations as well, I don't
> think there would be any difference in terms of parsing it, in the
> syntaxes that have been contemplated so far.  I think it's more
> intuitive to use the same name in declaration and use, not require an
> extra character for one but not the other.
> 
Received on Friday, 18 July 2008 20:15:39 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:55:10 GMT