Re: [css-variables] Why so inefficient?

On Wed, Feb 10, 2016 at 12:45 AM, darkdragon <darkdragon-001@web.de> wrote:
> Currently, you need at least 7(!) characters plus the actual name just to
> use one variable. This is quite much to encourage users to use it!
>
> Why do you need "--" AND "var()"?
> Wouldn't be one of it be enough?

We need the -- in var(--foo) so that the name matches exactly between
definition and use. Anything else is potentially confusing, and makes
searching in a document harder.

We need a var() function for a few reasons.  For one, there are a few
places in CSS where you can have arbitrary names already, like counter
styles or animation names, so allowing a bare custom property name
would be ambiguous there.  Theoretically we could make it invalid to
name your @keyframes or @counter-style rule something that looks like
a custom property name, but that means more rules for authors to
learn.

For two, var() is required in some circumstances, like when you want
to provide a fallback.  In general, a language shouldn't provide
multiple ways to do something unless there are good reasons for each,
and there isn't a strong reason to omit var() when you're not using
any other functionality, so I don't allow it.

> Why not something like "v()" as a shortcut (people using jQuery and stuff
> are used to such shortcuts!)?

While I highly value terseness in CSS and promote it whenever
possible, it must be balanced against other concerns, like readability
and understandability.  Single-letter names are generally a bad
tradeoff here - they only save a little bit, but they make it much
more difficult to tell what's being referred to.  The name "var()" is
already abbreviated from "variable()", but it's a pretty unambiguous
cut, and anyone working in the web platform is already familiar with
"var" from JS.

~TJ

Received on Tuesday, 16 February 2016 23:36:36 UTC