Skip to content
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

Add nil literal #361

Closed
wants to merge 1 commit into from
Closed

Add nil literal #361

wants to merge 1 commit into from

Conversation

petebrowne
Copy link

Here's a common use use case for a nil literal:

@mixin block-colors($background-color, $border-color: nil) {
  $border-color: darken($background-color, 10%) !default;

  background-color: $background-color;
  border-color: $border-color;
}

This is semantically different than using false in conjunction with an @if directive. Plus, guarded assignment can be used to set a dynamic default value.

@nex3
Copy link
Contributor

nex3 commented Apr 27, 2012

I think this is a good thing to add, but I think "null" is a better name for this. It's used by a wider variety of languages, including in particular Javascript.

I'll add more comments on the patch.

@petebrowne
Copy link
Author

I agree with the name change - I'll work on incorporating the changes you're suggesting. Thanks

@Anahkiasen
Copy link

I agree with the idea that null == 0 (but null !== 0), seems simpler and more logical to me.

@petebrowne
Copy link
Author

What do you think @nex3 @chriseppstein? Should 1 + null return 1 or raise a SyntaxError?

@chriseppstein
Copy link

Syntax error. We can relax it later if we feel it's wrong, but changing to syntax error later is very hard.

@nex3
Copy link
Contributor

nex3 commented Apr 30, 2012

I'm not at all fond of Javascript's aggressive type coercion. 1 + null should be an error, and null != 0.

@petebrowne petebrowne mentioned this pull request May 2, 2012
@petebrowne
Copy link
Author

I've opened a separate pull request, #374, with the suggested changes.

@petebrowne petebrowne closed this May 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants