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

"Reverse operands" meta-operator #33

Open
dloscutoff opened this issue Sep 12, 2021 · 2 comments
Open

"Reverse operands" meta-operator #33

dloscutoff opened this issue Sep 12, 2021 · 2 comments
Labels
brainstorming Less of an issue, more of a place to kick around ideas. enhancement

Comments

@dloscutoff
Copy link
Owner

dloscutoff commented Sep 12, 2021

Sometimes, it would be useful to reverse the operands of a binary operator. For example, to yank an expression and then use it as the lower bound of a Range:

(Ya+b),c

There is currently no way to save the parentheses, unless it's possible to rearrange the program so the yank happens first and then the expression is y,c.

If ~ were a meta-operator that swapped an operator's left and right operands, we could do

c,~Ya+b

potentially saving a byte.

TBD: What does the meta-operator do when applied to a ternary operator?

@chunkybanana
Copy link

If implemented, can this also reverse argument evaluation order?

@dloscutoff
Copy link
Owner Author

dloscutoff commented Feb 18, 2023

Interesting thought! I can see how that would be useful sometimes. From a quick look at the code, it also appears that the easiest way to implement ~ would be to swap the first and second branches of the expression's parse tree before evaluating, which would indeed result in the rhs being evaluated first. I'll have to think some more about how that would work when combined with the : meta-operator, though.

@dloscutoff dloscutoff added the brainstorming Less of an issue, more of a place to kick around ideas. label Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
brainstorming Less of an issue, more of a place to kick around ideas. enhancement
Projects
None yet
Development

No branches or pull requests

2 participants