W3C home > Mailing lists > Public > www-style@w3.org > April 2012

Re: [css-variables] Maintain link between var declaration and use

From: Chris Eppstein <chris@eppsteins.net>
Date: Mon, 30 Apr 2012 10:51:57 -0700
Message-ID: <CANyEp6UAogvsd4tUwKEn=aO7QrBvZp3AS6rGdWvXf=OKCJCPBA@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: "Jens O. Meiert" <jens@meiert.com>, www-style@w3.org
I strongly disagree with keeping the function based syntax for variable
access to provide future flexibility. The cascade of variables makes it
trivial to add defaults at variable declaration time, not at usage time. In
Sass we do it like this:

$foo: 10px !default;

And $foo is given a value of 10px if and only if $foo is not defined. This
approach is less cumbersome and already tried and tested.

Also, variable specific functions can be introduced later to handle other
use cases without needing a function in the simple use case.


On Mon, Apr 30, 2012 at 10:19 AM, Tab Atkins Jr. <jackalmage@gmail.com>wrote:

> On Mon, Apr 30, 2012 at 10:05 AM, Jens O. Meiert <jens@meiert.com> wrote:
> >> > In order to align variable declaration and use the format var-* may
> >> > suffice, or, as has been proposed in the past, using a special
> >> > character to denote variables as in @var-*.
> >>
> >> Can you elaborate?  I understand what you're saying in the first
> >> paragraph, but don't know what you're suggesting in the second.
> >
> > Yeah, that wasn’t very clear probably. I just played with two possible
> > solutions, one being “var-foo” for definition and also “var-foo” for
> > usage, the other one being “@var-foo” for definition and “@var-foo”
> > for usage. Both solutions would use the same pattern for declaration
> > and use though, addressing the original concern.
> Ah, got it.
> Using a bare "var-foo" keyword for variables wouldn't work unless we
> permanently reserved all keywords starting with "var-".  Possibly, but
> not ideal.  This also suffers from the same problem that using "$foo"
> does - if it's a single token, I can't expand its powers later, such
> as adding a default to be used if the var is undefined/invalid.
> There's an issue in the draft already about aligning the definition
> and use syntax, though the suggestion there is to use "var(foo):
> blue;".
> ~TJ
Received on Monday, 30 April 2012 17:52:28 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:15 UTC