Re: media queries syntax

On Thu, 15 Oct 2009, Bert Bos wrote:

> On Thursday 15 October 2009, Yves Lafon wrote:
>> Hi,
>> I am looking at the media-queries CR document [1], form a CSS
>> Validator standpoint, and I am wondering why the syntax of expression
>> is '(' .. ')' instead of using a function name like 'feature(' ...
>> ')'.
>
> I think it was never considered. So the question would more properly be
> the opposite: why is a functional notation better?
>
> There is no absolute answer, but here are a couple of considerations:
>
>  - Media Queries are used in CSS, but not only there. They also occur
>    in HTML (in the LINK and STYLE elements) and in XML (in the
>    xml-stylesheet PI). They are expressly designed to be used in yet
>    other places that we don't know about. Parentheses are a common
>    vocabulary that works almost anywhere.
>
>  - You may think that "feature()" is more readable, I think it just
>    adds redundancy and makes many expressions too long to fit nicely on
>    one line. :-)
>
>  - Parentheses are normal delimiters in CSS. They appear in the grammar
>    alongside functional notations, and together with the similar square
>    brackets. The grammar wasn't changed in any way to accommodate
>    Media Queries.

No, they are not. And the grammar _was_ changed to accomodate media 
queries...

http://www.w3.org/TR/2009/CR-css3-mediaqueries-20090915/#syntax

expression
  : '(' S* media_feature S* [':' S* expr]? ')' S*
  ;

Trying to parse (foo) with a CSS21 aprser based on CSS21 syntax will fail.

>> handling in other part of the spec for errors like
>> color: rgb (1,2,3); (instead of rgb(1,2,3);)
>
> But the validator already handles that, as far as I know. "rgb(" is one
> token, while "rgb (" is a pair of tokens. You get an error message that
> rgb isn't a valid color and that the rest of the value cannot be
> parsed.
Well, if you change the grammar and add the possibility of having '(...)' 
a valid construct, then the rest of the value _can_ be parsed, meaning 
that all the error handling has to be changed.

> Or do you mean that you want to add specific heuristics so that the
> error message can say that there is probably a space too many?

Heuristics are in the todo list, but not the reason of this message :)

>>
>> plus 'feature(...)' seems more readable than '(..)' (but that's
>> subjective
>>
>> :) ).
>
> Indeed it is. :-)

I told you ;)

>
>>
>> [1] http://www.w3.org/TR/2009/CR-css3-mediaqueries-20090915/
>
>
>
> Bert
>

-- 
Baroula que barouleras, au tiéu toujou t'entourneras.

         ~~Yves

Received on Friday, 16 October 2009 07:14:21 UTC