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

operator= assignment #301

Merged
merged 2 commits into from
Jan 29, 2023
Merged

operator= assignment #301

merged 2 commits into from
Jan 29, 2023

Conversation

edemaine
Copy link
Collaborator

This PR transforms x op= y into x = op(x, y), with the idea that op is a user-defined binary infix operator.

However, I have not restricted this to identifiers that have been blessed via operator. It just works for all identifiers. I think this is a good idea, but it does have the following impact:

x y= z used to parse as x(y=z) but now parses as x=y(x, z)

But note that spaces are required before and after y=, and the space before can't include a newline, which prevented falsely matching all existing tests. For example, x y=z still means x(y=z).

If we think this is too risky, we could protect it behind blessed operators with a one-line change.

@edemaine edemaine temporarily deployed to build January 28, 2023 22:06 — with GitHub Actions Inactive
@edemaine edemaine temporarily deployed to build January 28, 2023 22:06 — with GitHub Actions Inactive
@STRd6
Copy link
Contributor

STRd6 commented Jan 28, 2023

Looks good!

@STRd6
Copy link
Contributor

STRd6 commented Jan 28, 2023

It might be nice to see a test for something like:

x not contains= y

@edemaine
Copy link
Collaborator Author

I don't think that currently works... Should it mean x = !contains(x, y)?

@STRd6
Copy link
Contributor

STRd6 commented Jan 29, 2023

I'm not sure... but having a test documenting the current behavior would be nice.

@edemaine edemaine temporarily deployed to build January 29, 2023 15:45 — with GitHub Actions Inactive
@edemaine edemaine merged commit c222597 into main Jan 29, 2023
@edemaine edemaine deleted the identifier-assignment branch January 29, 2023 15:47
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.

2 participants