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

Proposal: Distributive Logical Operators #8533

Closed
alrz opened this issue Feb 10, 2016 · 0 comments
Closed

Proposal: Distributive Logical Operators #8533

alrz opened this issue Feb 10, 2016 · 0 comments

Comments

@alrz
Copy link
Contributor

alrz commented Feb 10, 2016

Using #6235 you can match an expression to a set of patterns like,

if(expr is Pattern1 or Pattern2)
if(expr is Pattern1 and Pattern2)

This issue proposes to use same set of operators in the lhs of is operator,

if(expr1 or expr2 is Pattern)
if(expr1 and expr2 is Pattern)

For example,

a or b is 5
a == 5 || b == 5

a and b is 5
a == 5 && b == 5

We can use both at the same time,

a or b is 1 or 5
(a == 1 || a == 5) || (b == 1 || b == 5)

a and b is 1 or 5
(a == 1 || a == 5) && (b == 1 || b == 5)

a and b is T
a is T && b is T

a is T or U
a is T || a is U

If the lhs contains an and operator, you can't use variables in your pattern, e.g.

if(a and b is T x) 

is illegal.

@alrz alrz changed the title Proposal: Distributive Operators Proposal: Distributive Logical Operators Feb 10, 2016
@alrz alrz closed this as completed Mar 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants