-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the behavior of prefixed variables more logical #809
Comments
yeah I'd like if they defaulted to |
Yep, we tried to use variables perfix-less initially, but then stumbled over a lot of issues with them. Anyway, it's a nice thing to migrate in the major version of Stylus — so if there'd be 1.0 version I'm all in for the prefix-only variables. Actually, there's a lot of things that can be done in Stylus and that are not back compatible: this, better syntax for interpolations with |
+1 for enforcing a $ prefix. |
+1 any progress on this? It's also weird that "an undefined identifier is still a truthy value". What was the thought behind that decision? for an undefined variable $foo
if variable equals an empty string
|
$prefix-only 👍 codemirror stylus mode will be happier 😃 |
Right now there is two ways to write and use variables — without the
$
prefix and with it.I like the way it is now, but there can be a lot of ways where the undeclared variables without value have the value like symbols makes things hard and ugly to do.
Those are:
is defined
, instead of just the conversion tofalse
(see Undefined variables return true in conditions #740).I propose this one thing: make the variables with
$
prefix don't work like symbols. Yes, it would make the two syntaxes of variables not equal, but you could get a lot of nice things with the prefixed var if you'd want. And it is something that won't have any problems on change — adding better behavior would only remove all those$foobar
went to CSS when things gone wrong. All theis defined
checks and all those things would work as usual.So, look at this example:
it looks awful!
But what if we'd add the desired behavior and with just adding prefix we'd get this nice code:
It's so much better!
The only thing we need to do is to convert the undeclared variables with
$
prefix tofalse
in boolean context, to empty string in string operations, to emptiness in cases likecolor: $foo
, to zero in math operations etc.@visionmedia what do you think? Is there any chance I could convince you to this? :)
The text was updated successfully, but these errors were encountered: