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 category list #2337

Open
lichtkind opened this issue Sep 29, 2018 · 6 comments
Open

operator category list #2337

lichtkind opened this issue Sep 29, 2018 · 6 comments
Labels
wishlist "nice to have" issues; might require a lot of work or a big change or be low priority

Comments

@lichtkind
Copy link
Contributor

The problem

I would like to see a list with all op categories like infix and some short guide what their signature is, and how to use them, since some of them are not trivial. I ask because I currently struggling to create a metaop.

Suggestions

maybe expand https://docs.perl6.org/language/operators, or since thats already very long create a new page for the language index that should be linked from there.

@lichtkind lichtkind added the wishlist "nice to have" issues; might require a lot of work or a big change or be low priority label Sep 29, 2018
@JJ
Copy link
Contributor

JJ commented Sep 29, 2018

infix is not really a category, it's a type of syntax. Those operators are already grouped by categories, like assignment or substitution. What you would want is a table of the kind of syntax every operator can use?

@lichtkind
Copy link
Contributor Author

I saw now https://docs.perl6.org/language/operators#Operator_classification and I'm still confused that syntax metops use are not on that list as it used to be. maybe i just miss doc: how to overload a metaop.

@lichtkind
Copy link
Contributor Author

alright let me rephrase:
when defining a operator like:

multi sub prefix:<->( Math::Matrix:D $m --> Math::Matrix:D) is export { $m.negated }

you use the keyword prefix you say the compiler how to parse things around - no matter if you call it category (which once was the proper term) or not you using this keyword. my question was which keyword i use is I want to overload X metaop like

multi sub meta-infix:<->(........ leftarg op rightarg) {....}

I read the sources of rakudo and get the feeling there is no way to do it this way.

@JJ
Copy link
Contributor

JJ commented Sep 30, 2018 via email

@lichtkind
Copy link
Contributor Author

thanks but not I want to overload meta X so i would take 3 args legt operand right most operand and right adjacent the reducing op. since i read the source I get the feeling that is not even planned for like X is only calling list on both operands and calling the reduce on the pairs. in case you wonder what is my motivation. during my talk i said tensor product is what x does anyway (logically), which is not correct X* is the right answer. so i stand before the joice to make an X* operator or introduce a proper X metaop that works on matrices.

@2colours
Copy link
Contributor

2colours commented Aug 5, 2023

I don't think you can introduce metaoperators. There is definitely no dedicated route for that but also, it's strongly intermixed with the parsing.

In theory, this could change with RakuAST, providing more macro-like possibilities but this particular feature is way into the future, if at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wishlist "nice to have" issues; might require a lot of work or a big change or be low priority
Projects
None yet
Development

No branches or pull requests

3 participants