doc icon indicating copy to clipboard operation
doc copied to clipboard

Distinguish which operators are Subs and which aren't

Open codesections opened this issue 3 years ago • 0 comments

It's fairly common to observe that, in Raku "operators are just functions with funny syntax". However, this is only mostly true: Raku contains a number of operators that aren't functions at all – but rather, that are syntax that compilers handle specially. We've previously discussed whether these non-Sub operators should be removed from the operators page but reached the consensus that the should remain. As @pmichaud put in #2267:

in many classical languages the "operators" have been syntactic constructs identified by the language definition, with no "Callable" behind them available to the programmer. This use of the term "operator" includes even sibling languages such as Perl 4 and Perl 5.

After reaching that consensus, we added the methodops to the operators doc (9cc1e2e32056088e91b5004f9b1787d5f713ef5e) and noted that they are handled specially. However, methodops aren't the only ops that aren't Subs – other examples include ==>/<==, the ternary operator, and all of the ff operators.

I suggest adding a paragraph at the beginning of the operators page explaining that operators are typically backed by Subs but noting that there are some exceptions and then calling out the exceptions as they come up in the page.

See also #3914, an issue I opened last July before I'd discovered the consensus in #2267 but which provided some helpful discussion.

codesections avatar Feb 12 '22 04:02 codesections