Skip to content

add unary + operator - #1170

Open
tr8dr wants to merge 1 commit into
wren-lang:mainfrom
tr8dr:main
Open

add unary + operator#1170
tr8dr wants to merge 1 commit into
wren-lang:mainfrom
tr8dr:main

Conversation

@tr8dr

@tr8dr tr8dr commented Jun 24, 2023

Copy link
Copy Markdown

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

mhermier commented Jun 24, 2023 via email

Copy link
Copy Markdown
Contributor

@ruby0x1

ruby0x1 commented Jun 24, 2023

Copy link
Copy Markdown
Member

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.

3 participants