Skip to content

Added guards checking to namespaces. - #2180

Closed
SomMeri wants to merge 1 commit into
less:masterfrom
SomMeri:namespaces-guards-1418
Closed

SomMeri wants to merge 1 commit into
less:masterfrom
SomMeri:namespaces-guards-1418

Conversation

@SomMeri

@SomMeri SomMeri commented Sep 5, 2014

Copy link
Copy Markdown
Member

Related to issue #1418.

Pull request adds guards and parameters checks to namespaces:

  • The #namespace(@variable) will not be used as namespace anymore.
  • The #namespace when (false_condition) will not be used as namespace anymore.
#namespace(@variable) { // mandatory parameter - can not be used as namespace
  .mixin() { mandatory: parameter;  }
}
@go: true;
#namespace(...) when (@go){ // ok
  .mixin() { works: works;  }
}
#namespace(@variable: default) when (@go){ // ok - parameter is optional
  .mixin() { optional: optional;  }
}
#namespace(...) when not(@go){  // false guard - can not be used as namespace
  .mixin() { guard: false;  }
}
.use {
  #namespace > .mixin();
}

compiles into:

.use {
  works: works;
  optional: optional;
}

How the default() function works: the default function is assumed to have the same value for all matched namespaces.

Following two namespaced mixins are matched exactly the same way:

#sp_1() when (default()) {
  .mixin() { /* */ }
}
#sp_1()  {
  .mixin() when (default()) { /* */ }
}

The mixin is never evaluated

#sp_1() when (default()) {
  .mixin() when not(default()) { /* */ }
}

@seven-phases-max

Copy link
Copy Markdown
Member

Wow. 👍 Though since it's actually a breaking change I guess this better to be released with v2?

@lukeapage

Copy link
Copy Markdown
Member

Good work. Yeh I can merge into v2.. I had a long flight yesterday and managed to make big progress on v2.. I think it might be ready soon ( ready means having all breaking changes in, not everything dreamed of)

@seven-phases-max

Copy link
Copy Markdown
Member

XRef: #1812 (I'm not sure though, is it?)

@SomMeri

SomMeri commented Sep 5, 2014

Copy link
Copy Markdown
Member Author

@seven-phases-max Nice finding, I completely forgotten about that issue and related discussion :).

@lukeapage

Copy link
Copy Markdown
Member

merged to the 2.0 branch

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.

3 participants