Re: [css-variables] Different syntax for variable definition and use

François REMY skriver:
>>> To me, the best solution is still { var-foo: xyz; var-bar: get(var-foo||fallback); }
>>
>> The last thing on earth I want is CCSS: Cryptic Cascading
>> StyleSheets. The above is cryptic. I disagree with the proposed
>> change.
> 
> Thanks for your sincerity. However I have a hard time understanding how "cryptic" the syntax is, especially when you look at the overloaded use of the comma.
> 
>     selector {
>         var-custom-bgs: url(a), url(b);
>         background: var(custom-bgs, url(c), url(d));
>     }
> 
> vs
> 
>     selector {
>         var-custom-bgs: url(a), url(b);
>         background: get(var-custom-bgs || url(a), url(b));
>     }
> 
> The double pipe (||) is universally recognized as the 'or' symbol, and this is exactly what it will be used for as most of the times. The 'get' name is really doing just what it's saying it does: getting the value of 'var-custom-bgs' or using 'url(a), url(b)' as a fallback value.
> 
> It also solve the issue of this thread (which did come up often: that the same identifier should be used while getting and setting a variable). At the same time, it's not suffering of Tab's issue that it should be clear from the syntax that a variable cannot be used as a property name.
> 
> Anyway, I'm not going to enumerate all of the advantages here, I've a better idea than to keep this thread going on and on. I hate feeling stuck in a swamp and I agree with you this thread certainly looks like one. 		 	   		  
> 
> 

The double pipe syntax reminds me of languages that define the boolean
or operator as returning the result of evaluating the second operand if
the first one doesn't evaluate to true.

I can't say that many people understand the implications of this as
opposed to how C and other languages work.

It is an unusual syntax that catches people off guard.

I am more a fan of the operand?:operand syntax that PHP is proposing. It
builds on the classical triway operator that C programmers are familiar
with.

For those that don't know it: PHP is starting to allow the middle
operand to be omitted, making it default to the value of the first operand.

Received on Wednesday, 20 February 2013 14:01:59 UTC