Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to define custom metaoperators in Raku?

Tags:

operators

raku

The standard way to define a new operator in Raku is

multi sub infix:<operator> ($l, $r) { ... }

With different options instead of infix. I would like to define a custom meta operator, however. The closest I can come (matching the idea of @a X+ @b) is

multi sub prefix:<F> (&bar) { ... }

But while it compiles, the only way to get it to work with, e.g., the + operator is to use an full identifier:

(F&infix:<+>)($a, $b)

Or are metaoperators definable?

like image 583
user0721090601 Avatar asked Aug 29 '20 05:08

user0721090601


1 Answers

You cannot currently define custom meta operators in Raku.

You might be able to get one to work through a slang, but with Rakudo-specifc code, and slangs aren't really well document -- the best you can do is google tutorials and examples, docs.raku.org is silent on them :-(

like image 64
moritz Avatar answered Nov 03 '22 01:11

moritz