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

Logical operator support #2266

Closed
am11 opened this issue Nov 2, 2014 · 4 comments
Closed

Logical operator support #2266

am11 opened this issue Nov 2, 2014 · 4 comments

Comments

@am11
Copy link
Contributor

am11 commented Nov 2, 2014

Don't know what spec has to say about it, but logically this code:

.foo {
    height: 1/2 ==   0.5 ?   3 : 2;
}

.bar {
  sanity: 1/2 ==   0.5;
}

Should compile to

.foo {
  height: 3;
}

.bar {
  sanity: true;
}

(at least this is how SASS do it)

Currently it throws:

ParseError: Unrecognised input in C:\temp\foo.less on line 2, column 5:
1 .foo {
2     height: 1/2 ==   0.5 ?   3 : 2;
3 }
@seven-phases-max
Copy link
Member

Well, Less development is sort of use-case driven, so even a useful feature thrown in w/o any real-world examples ("just because it can be added or just because Fortran has it") will barely go too far.
Either way see #1894.

@seven-phases-max
Copy link
Member

Closing as duplicate of #1894.

@am11
Copy link
Contributor Author

am11 commented Nov 2, 2014

just because it can be added or just because Fortran has it

Sorry for mentioning the rival brand :p

It's just a logical operation, you can think of handful of real-world use cases for this:

@denominator: 0.5;

selector {
  height: 1/2 ==   @denominator ?   3 : 2;
}

When implementing it, it would probably make sense to print true / false in case the usual ternary operation is missing:

@denominator: 0.5;

some-other-selector-with-dummy-property {
  dummy: 1/2 ==   @denominator;
}

// =>
// some-other-selector-with-dummy-property {
//  dummy: true;
//}

or not..

Peace! ✌️

@seven-phases-max
Copy link
Member

Sorry for mentioning the rival brand :p

It's absolutely OK to mention Sass here. My Fortran note was just a sarcastic remark hinting to the fact that Less as a language has very few to do with C-like languages (incl. Sass, JS or PHP) as well as with Fortran :) (I.e. when taking into account some C-like syntax or feature to be added one needs at least to consider possible conflicts with CSS syntax/selectors/ops/etc. Though this was mentioned in #1894 already I guess).

It's just a logical operation, you can think of handful of real-world use cases for this:

Yes, sure we all know what a ternary operator is. A use-example is better to answer "what for?" question (not just "what?" or "how?")... But, well,never mind - yet again see #1894.

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

No branches or pull requests

2 participants