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

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.

Chris

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