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

[glox] - Add support for comma operator #4

Open
silverhairs opened this issue Jul 2, 2023 · 0 comments
Open

[glox] - Add support for comma operator #4

silverhairs opened this issue Jul 2, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@silverhairs
Copy link
Owner

silverhairs commented Jul 2, 2023

The comma operator is used to separate multiple expressions within a single statement. It evaluates the left operand, discards the result, evaluates the right operand, and returns the result of the right operand. It is primarily used in situations where multiple expressions need to be executed in a specific order, such as in a for loop's increment section.

Since the operators precedences for lox are more or less the same as those of C, here is a precedence table with a couple of operators used by lox arranged in descending order of precedence:

Precedence Operator Description Associativity
Highest ?: Ternary conditional Right to left
== != Equality operators Left to right
! ~ ++ -- + - Unary operators Right to left
+ - Addition, subtraction Left to right
< <= > >= Relational operators Left to right
* / % Multiplication, division, modulo Left to right
, Comma operator Left to right
@silverhairs silverhairs added the enhancement New feature or request label Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant