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

Rule: unification used for variable assignment #3

Closed
anderseknert opened this issue Jan 24, 2023 · 3 comments
Closed

Rule: unification used for variable assignment #3

anderseknert opened this issue Jan 24, 2023 · 3 comments

Comments

@anderseknert
Copy link
Member

Avoid

x = 5

Prefer

x := 5

Motivation: while there are a few valid cases for unification, the unification operator (=) should not be used for simple assignment. TBD — more comprehensive explanation.

@anderseknert
Copy link
Member Author

The tricky thing in both this issue and #4 will be to determine whether unification really is intended — i.e. other constructs are less effective / elegant. For starters, I don't think we'll need to be too comprehensive in this check but just try and catch the simpler cases of one var/value on either side.

@anderseknert
Copy link
Member Author

anderseknert commented Jan 31, 2023

There is however a great number of cases where the := operator should be used unconditionally, and these would be easy to write checks for:

default allow = false 

f(x) = x

foo[x] = y { }

EDIT: And we do that now.

@anderseknert anderseknert changed the title Rule: unification used for assignment Rule: unification used for variable assignment Apr 13, 2023
@anderseknert
Copy link
Member Author

Closing in favor of #4, which will be remodeled to be "Unnecessary unification".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

1 participant