-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Spaces Inside Parentheses #952
Comments
I made some more experiments:
It seems like the left side decides what is going to happen with the right operand. |
There is already a java port.. you may want to consider helping that. On this issue we are currently working to say that values in parenthesis are evalulated as maths and without parenthesis are evaluated as-is. In your example
|
Thank you for the answer. The intended behavior makes a lot of sense :). Less for java project is a runner, it uses rhino interpreter to run less.js JavaScript implementation. As far as I know, the project works very well and gives 100% compatibility. Basically, they seems to be done. Less4j project tries to re-implement the language in Java using ANTLR, so its aim is a bit different. If it turns out that re-implementation leads anywhere or is slower or no one wants to use it anyway, I hope it will still count as a great learning experience. I also try to document as much as I can as I go, so even if the project would fail, I can contribute some documentation and maybe test cases (if there will be interest of course). |
Right now we allow any
Operation isn't performed and 12 is output...weird behavior. This should error because you're trying to perform: Look what happens when you do the reverse:
Not the best error message, but I think this is appropriate behavior for how the parser works right now.
Again, this is strange behavior and it's because you're multiplying a number by an object.
Same deal, trying to perform an operation with a number and an object. I think the questions this raises are:
Relevant lines in the parser: |
Thanks you, your answer clears up a lot. I think I understand now and know what is "as designed" and what is a bug. I think that if less.js would interpret parentheses as a math only, it would be easier to use and read. Having to be careful about the difference between There is one advantage of the current approach - consistency. Top level expressions and in parentheses expressions are evaluated the same way. So I can see the case for expressions in parentheses. However, the empty separator inside the parentheses and a comma should behave the same way. I do not see a relevant difference between them. I still prefer parentheses as math only, but maybe other people have different opinion. |
removed, we now give errors for all above cases. I have never come across a need for space seperated values inside parenthsis, but if the need comes up, we should handle it differently as mixing it with operations is prone to errors. |
When it comes to the space as a separator, it seems to be allowed inside parentheses too. This:
something: (12 (13 + 10 -23));
compiles intosomething: 12 23 -23;
.Is this a feature or a bug? The comma is treated differently and is not allowed inside parentheses:
something: (12,(13 + 10 -23));
leads to compile exception.I'm asking because I wanted to port less.js into java (https://github.com/SomMeri/less4j project) and would like to know whether:
I'm using less.js-1.3.0 release as a reference version. I also hope you do not mind too much java port of the compiler.
The text was updated successfully, but these errors were encountered: