Re: [css3-values] calc(), whitespace, and DIMENSION tokens

Paul Duffin wrote:
> 
> Andrei has hit the nail on the head. The reason for the problems with 
> the grammar for nth-child and calc is due to the way in which dimension 
> is specified. So either don't allow dimension in there, or redefine it.

Yeah, I thought about that, but then I realized it won't solve

   calc(3cm -4cm)

> A cleaner alternative is to simply disallow dimensions altogether within 
> general function syntax and instead provide a special function notation 
> for specifying the units, which could also be used in properties as 
> well. That would be slightly more verbose but I believe would be cleaner.
> 
> e.g.
> dim(3cm)-dim(2cm)
> calc(dim(3em)-max(dim(1em),dim(9px)))
> 
> That would require a special production for the dim(<DIMENSION>) 
> function but there is already precedent for that, e.g. not(<selector>).

Yuk. CSS is hand-authored: nobody wants to write /that/.

> If a more general yet easier to understand expression based selector is 
> required then I would suggest something more conventional along the 
> lines of:
> :if(p % 2 == 0) instead of :nth-child(2n)
> :if(p % 2 == 1) instead of :nth-child(2n+1)
> :if(p <= 4) instead of :nth-child(-n+4)
> :if(p > 4) instead of :nth-child(n-4)
> :if(p > 2 && p < 4) instead of :nth-child(n-2):nth-child(-n+3)
> :if(p == 9) instead of :nth-child(9)
> :if(p != 9) instead of :not(:nth-child(9))
> 
> :if() would require more operators than :nth-child() but I think is more 
> understandable, more flexible and easier to implement.

Adding :nth-child(n < 5) to Selectors Level 4 I can see, but
I don't think :if(p % 2 == 0) is easier to understand than
:nth-child(2n).

~fantasai

Received on Monday, 17 March 2008 17:49:10 UTC