Open lichtkind opened 5 years ago
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?
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.
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.
Would that be a circumfix operator? Maybe this operator classification is useful: https://docs.perl6.org/language/operators#Operator_classification
El dom., 30 sept. 2018 a las 5:27, Herbert Breunung (< notifications@github.com>) escribió:
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.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/perl6/doc/issues/2337#issuecomment-425691368, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAB9L0Sp45R1VnoeFWBp7Vhi6Gc5Y3Aks5ugDo8gaJpZM4XAfHx .
-- JJ
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.
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.
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.