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

Consider adding <op>== or <op>:= assignment operators with semantics closer to |='s #2708

Closed
nicowilliams opened this issue Jul 12, 2023 · 3 comments

Comments

@nicowilliams
Copy link
Contributor

nicowilliams commented Jul 12, 2023

See #1508, #2410.

We can't break backwards-compatibility and interoperability with gojq and jaq and others, but we could add new assignment operators.

@pkoppstein
Copy link
Contributor

pkoppstein commented Jul 13, 2023

Methinks <op>== looks too much like ==, whereas <op>:= does at least connote assignment.

Since these additions would be modeled after |= I was thinking that it might be helpful to include | in the mix,
e.g. +|=.

On the other hand, the absence of these operators for so many years doesn't seem to have caused anyone much grief, whereas their addition would tend to make programs more difficult to decipher.

(Most of whatever grief there has been, I believe, has been the result of bugs and/or inadequate or problematic documentation.)

@emanuele6
Copy link
Member

Yes, +|= would be a better syntax.

I also don't think those operators would be very useful. += does something that can't easily be replicated using = or |=, while foo +|= bar would just be syntax sugar for foo |= . + bar which is simple enough to write already

@nicowilliams
Copy link
Contributor Author

Excellent discussion. I'm going to close this now, but others should feel free to add their own two cents.

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

No branches or pull requests

3 participants