Re: [css-variables] Using $foo as the syntax for variables

On Thu, May 24, 2012 at 12:29 AM, Florian Rivoal <florianr@opera.com> wrote:
> On Wed, 23 May 2012 19:32:50 +0200, Tab Atkins Jr. <jackalmage@gmail.com>
> wrote:
>> In the new syntax, it would look something like this:
>> color: $bar //normal
>> color: default-var($bar, red) // default value
>> color: parent-var($bar) // bar from the parent
>> color: parent-var($bar, red) // bar from the parent, with a default value
>
>
> If we go with $ (which I still think we shouldn't), I think the above should
> be written like this instead:
>
> color: $bar //normal
> color: default-var(bar, red) // default value
>
> color: parent-var(bar) // bar from the parent
> color: parent-var(bar, red) // bar from the parent, with a default value
>
> Keeping the $ within the function, seems to imply that you want to expand
> the variable first, and then apply the function, giving the following
> behavior:
>
> ul {
>  $foo: red;
>  $bar: green;
> }
> li {
>  $foo: bar;
>  $bar: blue;
>  $background-color: parent-var($foo); /* you get green */
> }
>
> Also, having the following two be equivalent
>  color: $bar;
>  color: var(bar);
> Makes it possible to have multiple levels of indirection. Which you can't
> have with $, unless you want to allow this:
>  color: $$bar;

As much as possible, I prefer to have the syntax be consistent.
Having to remember that you use the $ in some circumstances but not
others is an annoying mental step.  In other words, the $ is *not*
just a disambiguator, it's actually part of the name.

I don't think multiple indirection has a use-case right now.  If it
ends up being useful, we can figure it out then; there are several
syntax possibilities that are compatible with my current proposal.

~TJ

Received on Thursday, 24 May 2012 17:07:06 UTC