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 unary + operator #1170

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

add unary + operator #1170

wants to merge 1 commit into from

Conversation

tr8dr
Copy link

@tr8dr tr8dr commented Jun 24, 2023

Added a unary '+' operator (+variable) to provide symmetry with the unary '-' operator (-variable). These operators are supported by most languages, so makes sense to include. Although unary '+' is effectively a NOP, it provides clarity in coding situations where want to contrast with the negation, where one may have code applying + and - to some magnitude.

In scripting often have symmetric rules, such as:

static rule_type1(alpha, beta, threshold1, threshold2) {
    return (alpha > -threshold1) && (beta < +threshold2)
}
static rule_type2(alpha, beta, threshold1, threshold2) {
    return (alpha < +threshold1) && (beta > -threshold2)
}

Having + and - magnitude clarifies the rules for us.

@mhermier
Copy link
Contributor

mhermier commented Jun 24, 2023 via email

@ruby0x1
Copy link
Member

ruby0x1 commented Jun 24, 2023

Thanks for the PR though @tr8dr , we always appreciate time spent

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

3 participants