Re: Proposal for adding variable declaration blocks

On Jul 1, 2008, at 4:07 PM, fantasai wrote:

>> (2) How to use the declaration block:
>> (a) Make up a fake property.
>> h1 {
>>  includes: headers;
>>  font-size: 24px;
>> }
>> (b) Make up a selector "annotation" notation
>> h1 includes headers {
>>  font-size: 24px;
>> }
>> (c) Make up some other kind of syntax
>> h1 {
>>  @includes headers;
>>  font-size: 24px;
>> }
>> I believe (b) is the most elegant notation.  The only disadvantage  
>> of (b) is that you would not be able to control the precise  
>> ordering (i.e., the properties would just occur at the front always  
>> and could not be precisely placed).
>
> I'd go with (c). (a) is a hack on property syntax.

I'd go with "a". It the simplest and most obvious. It may be a hack  
from the implementor point of view, but from the author point of view,  
it is a familiar way to assign values to properties. There is  
virtually nothing to remember.

Requiring an @ and taking out the colon (as with "c") just makes it  
more complicated and more prone to human error. @-signs do not belong  
inside rules that have already been assigned to selectors.

> And (b) is a hack
> on selector syntax, which is worse because, as Zachary points out,
> it's actually a valid selector. Plus lack of control and a worse
> fallback story... 3 strikes against.

I totally agree. "b" is the least elegant choice.

> I can't think of anything against (c).

I can. For starters, it just looks totally out of place inside the  
rule. Everything else inside rules such as this are assignees on the  
left, and what's being assigned to them on the right, with a colon in  
the middle. I want to be able to assign arrays of property/value  
duples the same way.

> Another possibility is to pick
> a character and use that for all dereferences, similar to the  
> scripting
> language $.
>
> h1 {
>  $headers;
>  background: $backgroundColor;
> }

Meh. I like { background: $backgroundColor; } much more than I like  
{ background: var(backgroundColor); }, but I like { background:  
backgroundColor; } the most. Keep it simple on the authors, even if it  
is a tiny amount of extra work for the implementors. So my version  
would look like this:

h1 {
  use: headers;
  background: backgroundColor;
}

Received on Wednesday, 2 July 2008 05:40:33 UTC