W3C home > Mailing lists > Public > www-style@w3.org > July 2008

Re: Proposal for adding variable declaration blocks

From: Simetrical <simetrical@gmail.com>
Date: Fri, 18 Jul 2008 13:40:26 -0400
Message-ID: <7c2a12e20807181040s2ba20ee3g49d96a251bb87ed9@mail.gmail.com>
To: "Brad Kemper" <brkemper@comcast.net>
Cc: fantasai <fantasai.lists@inkedblade.net>, "Mike Wilson" <mikewse@hotmail.com>, "www-style list" <www-style@w3.org>

On Fri, Jul 18, 2008 at 12:28 AM, Brad Kemper <brkemper@comcast.net> wrote:
> I do not understand the argument others have made that a dollar sign would
> be more natural. To me it is just another abstract symbol without anything
> to make it more understandable as a variable identifier. Is it because in
> some programming languages it is used to denote string-type variables?

In several languages it's used for all variables.  Shell scripts and
PHP prefix all variable names with $.  Perl prefixes all scalar
variable names with $ (with different sigils for lists and maps).
It's therefore a very natural convention to those who are used to
scripting languages, unless they only do Python and Ruby, or something
like that.  For instance, in PHP or Perl the following is a syntax
error:

var = 7;

You need to do this:

$var = 7;

Since a fairly large percentage of web authors probably know a little
PHP, it seems like a reasonable point to bring up.  If variables are
prefixed with $, some nontrivial percentage of people will immediately
get the syntax on first sight, while = will have to be learned anew by
everyone (unless there's someplace I know of that uses it for
variables).  And the same goes in the other direction, of course:
people used to $-prefixed variables in CSS will be more comfortable
with that convention in other languages.  If there's going to be some
abstract sigil used for variables, it may as well be one that's
already used in other standards.

=varname seems weird to me.  It would be a syntax error in practically
any programming language, since = is generally used for something
else.  It seems more natural to me to reserve = for equality testing
and/or assignment, or to use it in places that are clearly not at all
similar to existing programming constructs, to avoid confusion.

Of course, CSS is not a programming language and a large percentage of
its users are not programmers, but a large percentage are or will be
programmers, and it is a computer language.  If some preexisting
knowledge can be leveraged, I think that's good.  But it's not really
a big deal, in the end: it's a pretty trivial distinction to learn.
Received on Friday, 18 July 2008 17:41:02 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:55:10 GMT