- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Fri, 21 Jan 2011 14:02:28 -0800
- To: Brad Kemper <brad.kemper@gmail.com>
- Cc: "L. David Baron" <dbaron@dbaron.org>, "www-style@w3.org" <www-style@w3.org>
Sorry for the long delay. I forget things in my inbox, then go through a spasm of Inbox0 guilt. On Wed, Dec 29, 2010 at 11:59 AM, Brad Kemper <brad.kemper@gmail.com> wrote: > On Dec 29, 2010, at 10:48 AM, "Tab Atkins Jr." <jackalmage@gmail.com> wrote: >> 2010/12/29 Brad Kemper <brad.kemper@gmail.com>: >>> What is the harm of having unitless zero allowed? The benefit is that authors would not need to remember a special exception to unitless zeros that can be applied everywhere else that lengths are accepted. >> >> It's ambiguous. What's calc(0), a number or a length? > > If I had my druthers, it would depend on the property, just like anything else that accepts unitless zeros. If it was 'width: calc(0)' then it would be a length. However, since the spec starts out with saying that it can be used only as a length, then that is how it would end up. Hm. I guess that's a consistent position, though I don't see a particular benefit from it. >> Is calc(0 + >> 2em) valid? > > Sure, Okay, so you're leaning on the existing treatment of zero as an implicitly-unitted length when appropriate. >> What about calc(0 + 3)? > > Again, if not for the first sentence of the calc spec, I would say "only if the property accepted '3' as a value; 'width: calc(0 + 3)' would be ignored, but 'z-index: calc(0 + 3)' should be fine." However, because of that sentence, I'd have to say that the result of '3' is not a length, so "no". Makes sense. >> In calc(2em * 0 + 0), would 0 be >> a number both times, or a number the first time and a length the >> second? > > Mathmatically, it should be the same as '2 * em * 0 + 0'. You're assuming that multiplying a length by 0 switches it back to the ambiguous maybe-a-number-maybe-a-length state, so it's valid to then add either a number or length to it? > I would allow it, and also 'calc(2em * 1 + 1)'. I don't understand this one at all. "2em * 1" gives a length. How do you add a number and a length? Do you want to assume that unitless numbers, when added or subtracted from a length, should be interpreted as being in the same unit as the length? If so, how do you resolve "calc(2em + 10% + 1)" Is that different from "calc(2em + 1 + 10%)" or "calc(1 + 2em + 10%)" or "calc(10% + 2em + 1)"? ~TJ
Received on Friday, 21 January 2011 22:03:20 UTC