-
Notifications
You must be signed in to change notification settings - Fork 291
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
Comments
|
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: 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
<#2337 (comment)>, 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.
The text was updated successfully, but these errors were encountered: